Skip to content

Commit 211a0fb

Browse files
committed
call $nodeCallback() after loop
1 parent ea63923 commit 211a0fb

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ public function processNodes(
309309

310310
$alreadyTerminated = true;
311311
$nextStmts = $this->getNextUnreachableStatements(array_slice($nodes, $i + 1), true);
312+
313+
if ($nextStmts === []) {
314+
continue;
315+
}
316+
312317
$unreachableStatementNode = null;
313318
foreach ($nextStmts as $nextStmt) {
314319
if ($unreachableStatementNode instanceof UnreachableStatementNode) {
@@ -317,8 +322,9 @@ public function processNodes(
317322
}
318323

319324
$unreachableStatementNode = new UnreachableStatementNode($nextStmt);
320-
$nodeCallback($unreachableStatementNode, $scope);
321325
}
326+
327+
$nodeCallback($unreachableStatementNode, $scope);
322328
}
323329
}
324330

@@ -407,6 +413,10 @@ public function processStmtNodes(
407413
$alreadyTerminated = true;
408414
$nextStmts = $this->getNextUnreachableStatements(array_slice($stmts, $i + 1), $parentNode instanceof Node\Stmt\Namespace_);
409415

416+
if ($nextStmts === []) {
417+
continue;
418+
}
419+
410420
$unreachableStatementNode = null;
411421
foreach ($nextStmts as $nextStmt) {
412422
if ($unreachableStatementNode instanceof UnreachableStatementNode) {
@@ -415,8 +425,9 @@ public function processStmtNodes(
415425
}
416426

417427
$unreachableStatementNode = new UnreachableStatementNode($nextStmt);
418-
$nodeCallback($unreachableStatementNode, $scope);
419428
}
429+
430+
$nodeCallback($unreachableStatementNode, $scope);
420431
}
421432

422433
$statementResult = new StatementResult($scope, $hasYield, $alreadyTerminated, $exitPoints, $throwPoints, $impurePoints);
@@ -6211,7 +6222,7 @@ private function getPhpDocReturnType(ResolvedPhpDocBlock $resolvedPhpDoc, Type $
62116222
/**
62126223
* @template T of Node
62136224
* @param array<T> $nodes
6214-
* @return Node\Stmt[]
6225+
* @return list<Node\Stmt>
62156226
*/
62166227
private function getNextUnreachableStatements(array $nodes, bool $earlyBinding): array
62176228
{
@@ -6223,7 +6234,7 @@ private function getNextUnreachableStatements(array $nodes, bool $earlyBinding):
62236234
if ($earlyBinding && ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassLike || $node instanceof Node\Stmt\HaltCompiler)) {
62246235
continue;
62256236
}
6226-
if (! $node instanceof Node\Stmt) {
6237+
if (!$node instanceof Node\Stmt) {
62276238
continue;
62286239
}
62296240
$stmts[] = $node;

0 commit comments

Comments
 (0)