@@ -4536,11 +4536,14 @@ private function inferForLoopExpressions(For_ $stmt, Expr $lastCondExpr, Mutatin
45364536 && $ stmt ->init [0 ]->var ->name === $ lastCondExpr ->left ->name
45374537 ) {
45384538 $ arrayArg = $ lastCondExpr ->right ->getArgs ()[0 ]->value ;
4539- $ bodyScope = $ bodyScope ->assignExpression (
4540- new ArrayDimFetch ($ lastCondExpr ->right ->getArgs ()[0 ]->value , $ lastCondExpr ->left ),
4541- $ bodyScope ->getType ($ arrayArg )->getIterableValueType (),
4542- $ bodyScope ->getNativeType ($ arrayArg )->getIterableValueType (),
4543- );
4539+ $ arrayType = $ bodyScope ->getType ($ arrayArg );
4540+ if ($ arrayType ->isList ()->yes ()) {
4541+ $ bodyScope = $ bodyScope ->assignExpression (
4542+ new ArrayDimFetch ($ lastCondExpr ->right ->getArgs ()[0 ]->value , $ lastCondExpr ->left ),
4543+ $ arrayType ->getIterableValueType (),
4544+ $ bodyScope ->getNativeType ($ arrayArg )->getIterableValueType (),
4545+ );
4546+ }
45444547 }
45454548
45464549 // count($items) > $i
@@ -4557,11 +4560,14 @@ private function inferForLoopExpressions(For_ $stmt, Expr $lastCondExpr, Mutatin
45574560 && $ stmt ->init [0 ]->var ->name === $ lastCondExpr ->right ->name
45584561 ) {
45594562 $ arrayArg = $ lastCondExpr ->left ->getArgs ()[0 ]->value ;
4560- $ bodyScope = $ bodyScope ->assignExpression (
4561- new ArrayDimFetch ($ lastCondExpr ->left ->getArgs ()[0 ]->value , $ lastCondExpr ->right ),
4562- $ bodyScope ->getType ($ arrayArg )->getIterableValueType (),
4563- $ bodyScope ->getNativeType ($ arrayArg )->getIterableValueType (),
4564- );
4563+ $ arrayType = $ bodyScope ->getType ($ arrayArg );
4564+ if ($ arrayType ->isList ()->yes ()) {
4565+ $ bodyScope = $ bodyScope ->assignExpression (
4566+ new ArrayDimFetch ($ lastCondExpr ->left ->getArgs ()[0 ]->value , $ lastCondExpr ->right ),
4567+ $ arrayType ->getIterableValueType (),
4568+ $ bodyScope ->getNativeType ($ arrayArg )->getIterableValueType (),
4569+ );
4570+ }
45654571 }
45664572 }
45674573
0 commit comments