@@ -51,11 +51,7 @@ public function ensureShallowNonNullability(MutatingScope $scope, Scope $origina
5151 return new EnsuredNonNullabilityResult ($ scope , []);
5252 }
5353
54- $ nativeType = $ scope ->getNativeType ($ exprToSpecify );
55-
56- $ specifiedExpressions = [
57- new EnsuredNonNullabilityResultExpression ($ exprToSpecify , $ exprType , $ nativeType , $ certainty ),
58- ];
54+ $ specifiedExpressions = [];
5955
6056 // When narrowing an ArrayDimFetch, specifyExpressionType also recursively
6157 // narrows the parent array's offset type via intersection with HasOffsetValueType.
@@ -64,14 +60,16 @@ public function ensureShallowNonNullability(MutatingScope $scope, Scope $origina
6460 $ parentExpr = $ exprToSpecify ->var ;
6561 $ hasParentExpressionType = $ originalScope ->hasExpressionType ($ parentExpr );
6662
67- array_unshift ( $ specifiedExpressions, new EnsuredNonNullabilityResultExpression (
63+ $ specifiedExpressions[] = new EnsuredNonNullabilityResultExpression (
6864 $ parentExpr ,
6965 $ scope ->getType ($ parentExpr ),
7066 $ scope ->getNativeType ($ parentExpr ),
7167 $ hasParentExpressionType ,
72- )) ;
68+ );
7369 }
7470
71+ $ nativeType = $ scope ->getNativeType ($ exprToSpecify );
72+ $ specifiedExpressions [] = new EnsuredNonNullabilityResultExpression ($ exprToSpecify , $ exprType , $ nativeType , $ certainty );
7573 $ scope = $ scope ->specifyExpressionType (
7674 $ exprToSpecify ,
7775 $ exprTypeWithoutNull ,
0 commit comments