@@ -1501,7 +1501,9 @@ private function lookForEnterVariableAssign(MutatingScope $scope, Expr $expr): M
15011501
15021502private function lookForExitVariableAssign (MutatingScope $ scope , Expr $ expr ): MutatingScope
15031503{
1504- $ scope = $ scope ->exitExpressionAssign ($ expr );
1504+ if (!$ expr instanceof ArrayDimFetch || $ expr ->dim !== null ) {
1505+ $ scope = $ scope ->exitExpressionAssign ($ expr );
1506+ }
15051507if (!$ expr instanceof Variable) {
15061508return $ this ->lookForVariableAssignCallback ($ scope , $ expr , static fn (MutatingScope $ scope , Expr $ expr ): MutatingScope => $ scope ->exitExpressionAssign ($ expr ));
15071509}
@@ -1517,11 +1519,11 @@ private function lookForVariableAssignCallback(MutatingScope $scope, Expr $expr,
15171519if ($ expr instanceof Variable) {
15181520$ scope = $ callback ($ scope , $ expr );
15191521} elseif ($ expr instanceof ArrayDimFetch) {
1520- while ($ expr instanceof ArrayDimFetch ) {
1521- $ expr = $ expr-> var ;
1522+ if ($ expr-> dim !== null ) {
1523+ $ scope = $ callback ( $ scope , $ expr) ;
15221524}
15231525
1524- $ scope = $ this ->lookForVariableAssignCallback ($ scope , $ expr , $ callback );
1526+ $ scope = $ this ->lookForVariableAssignCallback ($ scope , $ expr-> var , $ callback );
15251527} elseif ($ expr instanceof PropertyFetch || $ expr instanceof Expr \NullsafePropertyFetch) {
15261528$ scope = $ this ->lookForVariableAssignCallback ($ scope , $ expr ->var , $ callback );
15271529} elseif ($ expr instanceof StaticPropertyFetch) {
0 commit comments