Skip to content

Commit

Permalink
Reduce count() usage on PHPStanNodeScopeResolver (#4102)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jun 7, 2023
1 parent f4f94bc commit aa0c9af
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ public function processNodes(
Assert::allIsInstanceOf($stmts, Stmt::class);
$this->nodeTraverser->traverse($stmts);

$isFileWithoutNamespace = count($stmts) === 1 && $stmts[0] instanceof FileWithoutNamespace;
if (! $isScopeRefreshing && ! $isFileWithoutNamespace) {
if (! $isScopeRefreshing && ! current($stmts) instanceof FileWithoutNamespace) {
$stmts = $this->fileWithoutNamespaceNodeTraverser->traverse($stmts);

if (count($stmts) === 1 && $stmts[0] instanceof FileWithoutNamespace) {
$stmts = $stmts[0]->stmts;
$currentStmt = current($stmts);
if ($currentStmt instanceof FileWithoutNamespace) {
$stmts = $currentStmt->stmts;
}
}

Expand Down

0 comments on commit aa0c9af

Please sign in to comment.