@@ -3198,15 +3198,20 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
31983198 $ impurePoints = array_merge ($ impurePoints , $ result ->getImpurePoints ());
31993199 $ isAlwaysTerminating = $ isAlwaysTerminating || $ result ->isAlwaysTerminating ();
32003200 } elseif ($ expr instanceof Expr \NullsafeMethodCall) {
3201+ $ this ->processExprNode ($ stmt , new MethodCall (
3202+ $ expr ->var ,
3203+ $ expr ->name ,
3204+ $ expr ->args ,
3205+ ), $ scope , $ storage , new NoopNodeCallback (), $ context );
32013206 $ nonNullabilityResult = $ this ->ensureShallowNonNullability ($ scope , $ scope , $ expr ->var );
32023207 $ attributes = array_merge ($ expr ->getAttributes (), ['virtualNullsafeMethodCall ' => true ]);
32033208 unset($ attributes [ExprPrinter::ATTRIBUTE_CACHE_KEY ]);
32043209 $ exprResult = $ this ->processExprNode (
32053210 $ stmt ,
32063211 new MethodCall (
3207- $ expr ->var ,
3208- $ expr ->name ,
3209- $ expr ->args ,
3212+ $ this -> deepNodeCloner -> cloneNode ( $ expr ->var ) ,
3213+ $ this -> deepNodeCloner -> cloneNode ( $ expr ->name ) ,
3214+ array_map ( fn ( $ node ) => $ this -> deepNodeCloner -> cloneNode ( $ node ), $ expr ->args ) ,
32103215 $ attributes ,
32113216 ),
32123217 $ nonNullabilityResult ->getScope (),
@@ -3423,12 +3428,16 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
34233428 }
34243429 }
34253430 } elseif ($ expr instanceof Expr \NullsafePropertyFetch) {
3431+ $ this ->processExprNode ($ stmt , new PropertyFetch (
3432+ $ expr ->var ,
3433+ $ expr ->name ,
3434+ ), $ scope , $ storage , new NoopNodeCallback (), $ context );
34263435 $ nonNullabilityResult = $ this ->ensureShallowNonNullability ($ scope , $ scope , $ expr ->var );
34273436 $ attributes = array_merge ($ expr ->getAttributes (), ['virtualNullsafePropertyFetch ' => true ]);
34283437 unset($ attributes [ExprPrinter::ATTRIBUTE_CACHE_KEY ]);
34293438 $ exprResult = $ this ->processExprNode ($ stmt , new PropertyFetch (
3430- $ expr ->var ,
3431- $ expr ->name ,
3439+ $ this -> deepNodeCloner -> cloneNode ( $ expr ->var ) ,
3440+ $ this -> deepNodeCloner -> cloneNode ( $ expr ->name ) ,
34323441 $ attributes ,
34333442 ), $ nonNullabilityResult ->getScope (), $ storage , $ nodeCallback , $ context );
34343443 $ scope = $ this ->revertNonNullability ($ exprResult ->getScope (), $ nonNullabilityResult ->getSpecifiedExpressions ());
@@ -3620,9 +3629,10 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
36203629 static fn (): MutatingScope => $ rightResult ->getScope ()->filterByFalseyValue ($ expr ),
36213630 );
36223631 } elseif ($ expr instanceof Coalesce) {
3632+ $ this ->processExprNode ($ stmt , $ expr ->left , $ scope , $ storage , new NoopNodeCallback (), $ context ->enterDeep ());
36233633 $ nonNullabilityResult = $ this ->ensureNonNullability ($ scope , $ expr ->left );
36243634 $ condScope = $ this ->lookForSetAllowedUndefinedExpressions ($ nonNullabilityResult ->getScope (), $ expr ->left );
3625- $ condResult = $ this ->processExprNode ($ stmt , $ expr ->left , $ condScope , $ storage , $ nodeCallback , $ context ->enterDeep ());
3635+ $ condResult = $ this ->processExprNode ($ stmt , $ this -> deepNodeCloner -> cloneNode ( $ expr ->left ) , $ condScope , $ storage , $ nodeCallback , $ context ->enterDeep ());
36263636 $ scope = $ this ->revertNonNullability ($ condResult ->getScope (), $ nonNullabilityResult ->getSpecifiedExpressions ());
36273637 $ scope = $ this ->lookForUnsetAllowedUndefinedExpressions ($ scope , $ expr ->left );
36283638
@@ -3819,9 +3829,10 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
38193829 $ this ->callNodeCallback ($ nodeCallback , $ expr ->name , $ scope , $ storage );
38203830 }
38213831 } elseif ($ expr instanceof Expr \Empty_) {
3832+ $ this ->processExprNode ($ stmt , $ expr ->expr , $ scope , $ storage , new NoopNodeCallback (), $ context ->enterDeep ());
38223833 $ nonNullabilityResult = $ this ->ensureNonNullability ($ scope , $ expr ->expr );
38233834 $ scope = $ this ->lookForSetAllowedUndefinedExpressions ($ nonNullabilityResult ->getScope (), $ expr ->expr );
3824- $ result = $ this ->processExprNode ($ stmt , $ expr ->expr , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
3835+ $ result = $ this ->processExprNode ($ stmt , $ this -> deepNodeCloner -> cloneNode ( $ expr ->expr ) , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
38253836 $ scope = $ result ->getScope ();
38263837 $ hasYield = $ result ->hasYield ();
38273838 $ throwPoints = $ result ->getThrowPoints ();
@@ -3836,9 +3847,10 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
38363847 $ nonNullabilityResults = [];
38373848 $ isAlwaysTerminating = false ;
38383849 foreach ($ expr ->vars as $ var ) {
3850+ $ this ->processExprNode ($ stmt , $ var , $ scope , $ storage , new NoopNodeCallback (), $ context ->enterDeep ());
38393851 $ nonNullabilityResult = $ this ->ensureNonNullability ($ scope , $ var );
38403852 $ scope = $ this ->lookForSetAllowedUndefinedExpressions ($ nonNullabilityResult ->getScope (), $ var );
3841- $ result = $ this ->processExprNode ($ stmt , $ var , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
3853+ $ result = $ this ->processExprNode ($ stmt , $ this -> deepNodeCloner -> cloneNode ( $ var) , $ scope , $ storage , $ nodeCallback , $ context ->enterDeep ());
38423854 $ scope = $ result ->getScope ();
38433855 $ hasYield = $ hasYield || $ result ->hasYield ();
38443856 $ throwPoints = array_merge ($ throwPoints , $ result ->getThrowPoints ());
0 commit comments