Skip to content

Commit 4a08845

Browse files
committed
Fix foreach processing
1 parent d09f754 commit 4a08845

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,9 @@ private function processStmtNode(
12481248
$this->processTraitUse($stmt, $scope, $traitStorage, $nodeCallback);
12491249
$this->processPendingFibers($traitStorage);
12501250
} elseif ($stmt instanceof Foreach_) {
1251+
if ($stmt->expr instanceof Variable && is_string($stmt->expr->name)) {
1252+
$scope = $this->processVarAnnotation($scope, [$stmt->expr->name], $stmt);
1253+
}
12511254
$condResult = $this->processExprNode($stmt, $stmt->expr, $scope, $storage, $nodeCallback, ExpressionContext::createDeep());
12521255
$throwPoints = $overridingThrowPoints ?? $condResult->getThrowPoints();
12531256
$impurePoints = $condResult->getImpurePoints();
@@ -1256,9 +1259,6 @@ private function processStmtNode(
12561259
$stmt->expr,
12571260
new Array_([]),
12581261
);
1259-
if ($stmt->expr instanceof Variable && is_string($stmt->expr->name)) {
1260-
$scope = $this->processVarAnnotation($scope, [$stmt->expr->name], $stmt);
1261-
}
12621262
$this->callNodeCallback($nodeCallback, new InForeachNode($stmt), $scope, $storage);
12631263
$originalScope = $scope;
12641264
$bodyScope = $scope;

0 commit comments

Comments
 (0)