From b41f52060a357c4824f2bbf9f3f02f8149bc27d2 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sat, 6 Jul 2024 10:08:27 +0200 Subject: [PATCH] Move code around a bit --- src/Analyser/MutatingScope.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index c2ae0e2177..64e53c478e 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -1318,12 +1318,6 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu $impurePoints = array_merge($arrowFunctionImpurePoints, $arrowFunctionExprResult->getImpurePoints()); $usedVariables = []; } else { - $closureScope = $this->enterAnonymousFunctionWithoutReflection($node, $callableParameters); - $closureReturnStatements = []; - $closureYieldStatements = []; - $closureExecutionEnds = []; - $closureImpurePoints = []; - $invalidateExpressions = []; if (self::$resolveClosureTypeDepth >= 2) { return new ClosureType( $parameters, @@ -1333,6 +1327,14 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu } self::$resolveClosureTypeDepth++; + + $closureScope = $this->enterAnonymousFunctionWithoutReflection($node, $callableParameters); + $closureReturnStatements = []; + $closureYieldStatements = []; + $closureExecutionEnds = []; + $closureImpurePoints = []; + $invalidateExpressions = []; + try { $closureStatementResult = $this->nodeScopeResolver->processStmtNodes($node, $node->stmts, $closureScope, static function (Node $node, Scope $scope) use ($closureScope, &$closureReturnStatements, &$closureYieldStatements, &$closureExecutionEnds, &$closureImpurePoints, &$invalidateExpressions): void { if ($scope->getAnonymousFunctionReflection() !== $closureScope->getAnonymousFunctionReflection()) {