@@ -342,10 +342,10 @@ public function processNodes(
342342 $ this ->processPendingFibers ($ expressionResultStorage );
343343 }
344344
345- private function storeBeforeScope (ExpressionResultStorage $ storage , Expr $ expr , ExpressionResult $ result ): void
345+ private function storeBeforeScope (ExpressionResultStorage $ storage , Expr $ expr , Scope $ beforeScope ): void
346346 {
347- $ storage ->storeBeforeScope ($ expr , $ result -> getBeforeScope () );
348- $ this ->processPendingFibersForRequestedExpr ($ storage , $ expr , $ result -> getBeforeScope () );
347+ $ storage ->storeBeforeScope ($ expr , $ beforeScope );
348+ $ this ->processPendingFibersForRequestedExpr ($ storage , $ expr , $ beforeScope );
349349 }
350350
351351 protected function processPendingFibers (ExpressionResultStorage $ storage ): void
@@ -2559,7 +2559,7 @@ public function processExprNode(
25592559 }
25602560
25612561 $ newExprResult = $ this ->processExprNode ($ stmt , $ newExpr , $ scope , $ storage , $ nodeCallback , $ context );
2562- $ this ->storeBeforeScope ($ storage , $ expr , $ newExprResult );
2562+ $ this ->storeBeforeScope ($ storage , $ expr , $ newExprResult-> getBeforeScope () );
25632563 return $ newExprResult ;
25642564 }
25652565
@@ -2631,7 +2631,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
26312631 }
26322632
26332633 $ result = new ExpressionResult ($ scope , $ beforeScope , $ hasYield , $ isAlwaysTerminating , $ throwPoints , $ impurePoints );
2634- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
2634+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
26352635
26362636 return $ result ;
26372637 },
@@ -2688,7 +2688,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
26882688 $ result ->getThrowPoints (),
26892689 $ result ->getImpurePoints (),
26902690 );
2691- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
2691+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
26922692
26932693 return $ result ;
26942694 }
@@ -2699,7 +2699,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
26992699 );
27002700 $ scope = $ result ->getScope ();
27012701 if (!$ expr instanceof Expr \AssignOp \Coalesce) {
2702- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
2702+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
27032703 }
27042704 $ hasYield = $ result ->hasYield ();
27052705 $ throwPoints = $ result ->getThrowPoints ();
@@ -3228,7 +3228,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
32283228 static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
32293229 static fn (): MutatingScope => $ scope ->filterByFalseyValue ($ expr ),
32303230 );
3231- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3231+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
32323232
32333233 return $ result ;
32343234 } elseif ($ expr instanceof StaticCall) {
@@ -3448,7 +3448,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
34483448 static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
34493449 static fn (): MutatingScope => $ scope ->filterByFalseyValue ($ expr ),
34503450 );
3451- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3451+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
34523452
34533453 return $ result ;
34543454 } elseif ($ expr instanceof StaticPropertyFetch) {
@@ -3493,7 +3493,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
34933493 [],
34943494 [],
34953495 );
3496- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3496+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
34973497
34983498 return $ result ;
34993499 } elseif ($ expr instanceof Expr \ArrowFunction) {
@@ -3506,7 +3506,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
35063506 [],
35073507 [],
35083508 );
3509- $ this ->storeBeforeScope ($ storage , $ expr , $ exprResult );
3509+ $ this ->storeBeforeScope ($ storage , $ expr , $ exprResult-> getBeforeScope () );
35103510 return $ exprResult ;
35113511 } elseif ($ expr instanceof ErrorSuppress) {
35123512 $ result = $ this ->processExprNode ($ stmt , $ expr ->expr , $ scope , $ storage , $ nodeCallback , $ context );
@@ -3615,7 +3615,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36153615 static fn (): MutatingScope => $ rightResult ->getScope ()->filterByTruthyValue ($ expr ),
36163616 static fn (): MutatingScope => $ leftMergedWithRightScope ->filterByFalseyValue ($ expr ),
36173617 );
3618- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3618+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
36193619 return $ result ;
36203620 } elseif ($ expr instanceof BooleanOr || $ expr instanceof BinaryOp \LogicalOr) {
36213621 $ leftResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
@@ -3639,7 +3639,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36393639 static fn (): MutatingScope => $ leftMergedWithRightScope ->filterByTruthyValue ($ expr ),
36403640 static fn (): MutatingScope => $ rightResult ->getScope ()->filterByFalseyValue ($ expr ),
36413641 );
3642- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3642+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
36433643 return $ result ;
36443644 } elseif ($ expr instanceof Coalesce) {
36453645 $ nonNullabilityResult = $ this ->ensureNonNullability ($ scope , $ expr ->left );
@@ -3890,7 +3890,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
38903890 } elseif ($ expr instanceof List_) {
38913891 // only in assign and foreach, processed elsewhere
38923892 $ result = new ExpressionResult ($ scope , $ scope , false , false , [], []);
3893- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
3893+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
38943894
38953895 return $ result ;
38963896 } elseif ($ expr instanceof New_) {
@@ -4116,7 +4116,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
41164116 static fn (): MutatingScope => $ finalScope ->filterByTruthyValue ($ expr ),
41174117 static fn (): MutatingScope => $ finalScope ->filterByFalseyValue ($ expr ),
41184118 );
4119- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
4119+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
41204120 return $ result ;
41214121
41224122 } elseif ($ expr instanceof Expr \Yield_) {
@@ -4379,7 +4379,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
43794379 $ impurePoints = $ result ->getImpurePoints ();
43804380 $ isAlwaysTerminating = $ result ->isAlwaysTerminating ();
43814381 $ scope = $ result ->getScope ();
4382- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
4382+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
43834383
43844384 $ expr = $ expr ->getExpr ();
43854385 } elseif ($ expr instanceof Expr \Throw_) {
@@ -4479,7 +4479,7 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
44794479 static fn (): MutatingScope => $ scope ->filterByTruthyValue ($ expr ),
44804480 static fn (): MutatingScope => $ scope ->filterByFalseyValue ($ expr ),
44814481 );
4482- $ this ->storeBeforeScope ($ storage , $ expr , $ result );
4482+ $ this ->storeBeforeScope ($ storage , $ expr , $ result-> getBeforeScope () );
44834483 return $ result ;
44844484 }
44854485
@@ -5661,7 +5661,7 @@ private function processArgs(
56615661 $ isAlwaysTerminating = $ isAlwaysTerminating || $ closureResult ->isAlwaysTerminating ();
56625662 }
56635663
5664- $ this ->storeBeforeScope ($ storage , $ arg ->value , new ExpressionResult ( $ closureResult -> getScope (), $ scopeToPass, false , $ isAlwaysTerminating , $ throwPoints , $ impurePoints ) );
5664+ $ this ->storeBeforeScope ($ storage , $ arg ->value , $ scopeToPass );
56655665
56665666 $ uses = [];
56675667 foreach ($ arg ->value ->uses as $ use ) {
@@ -5717,7 +5717,7 @@ private function processArgs(
57175717 $ impurePoints = array_merge ($ impurePoints , $ arrowFunctionResult ->getImpurePoints ());
57185718 $ isAlwaysTerminating = $ isAlwaysTerminating || $ arrowFunctionResult ->isAlwaysTerminating ();
57195719 }
5720- $ this ->storeBeforeScope ($ storage , $ arg ->value , new ExpressionResult ( $ arrowFunctionResult -> getScope (), $ scopeToPass, false , $ isAlwaysTerminating , $ throwPoints , $ impurePoints ) );
5720+ $ this ->storeBeforeScope ($ storage , $ arg ->value , $ scopeToPass );
57215721 } else {
57225722 $ exprType = $ scope ->getType ($ arg ->value );
57235723 $ exprResult = $ this ->processExprNode ($ stmt , $ arg ->value , $ scopeToPass , $ storage , $ nodeCallback , $ context ->enterDeep ());
@@ -5947,6 +5947,7 @@ private function processAssignVar(
59475947 bool $ enterExpressionAssign ,
59485948 ): ExpressionResult
59495949 {
5950+ $ this ->storeBeforeScope ($ storage , $ var , $ scope );
59505951 $ originalScope = $ scope ;
59515952 $ this ->callNodeCallback ($ nodeCallback , $ var , $ enterExpressionAssign ? $ scope ->enterExpressionAssign ($ var ) : $ scope , $ storage );
59525953 $ hasYield = false ;
0 commit comments