@@ -1467,8 +1467,6 @@ private function resolveType(string $exprString, Expr $node): Type
14671467 $ node ->var ,
14681468 $ this ->getTypeFromArrayDimFetch (
14691469 $ node ,
1470- $ this ->getType ($ node ->dim ),
1471- $ this ->getType ($ node ->var ),
14721470 ),
14731471 );
14741472 }
@@ -1845,14 +1843,13 @@ private function promoteNativeTypes(): self
18451843
18461844 private function getTypeFromArrayDimFetch (
18471845 Expr \ArrayDimFetch $ arrayDimFetch ,
1848- Type $ offsetType ,
1849- Type $ offsetAccessibleType ,
18501846 ): Type
18511847 {
18521848 if ($ arrayDimFetch ->dim === null ) {
18531849 throw new ShouldNotHappenException ();
18541850 }
18551851
1852+ $ offsetAccessibleType = $ this ->getType ($ arrayDimFetch ->var );
18561853 if ($ offsetAccessibleType instanceof NeverType) {
18571854 return $ offsetAccessibleType ;
18581855 }
@@ -1872,6 +1869,7 @@ private function getTypeFromArrayDimFetch(
18721869 );
18731870 }
18741871
1872+ $ offsetType = $ this ->getType ($ arrayDimFetch ->dim );
18751873 return $ offsetAccessibleType ->getOffsetValueType ($ offsetType );
18761874 }
18771875
@@ -4143,17 +4141,21 @@ private function createConditionalExpressions(
41434141 continue ;
41444142 }
41454143
4146- $ conditionalExpression = new ConditionalExpressionHolder ($ variableTypeGuards , $ holder );
4147- $ conditionalExpressions [$ exprString ][$ conditionalExpression ->getKey ()] = $ conditionalExpression ;
4144+ foreach ($ variableTypeGuards as $ guardExprString => $ guardHolder ) {
4145+ $ conditionalExpression = new ConditionalExpressionHolder ([$ guardExprString => $ guardHolder ], $ holder );
4146+ $ conditionalExpressions [$ exprString ][$ conditionalExpression ->getKey ()] = $ conditionalExpression ;
4147+ }
41484148 }
41494149
41504150 foreach ($ mergedExpressionTypes as $ exprString => $ mergedExprTypeHolder ) {
41514151 if (array_key_exists ($ exprString , $ ourExpressionTypes )) {
41524152 continue ;
41534153 }
41544154
4155- $ conditionalExpression = new ConditionalExpressionHolder ($ typeGuards , new ExpressionTypeHolder ($ mergedExprTypeHolder ->getExpr (), new ErrorType (), TrinaryLogic::createNo ()));
4156- $ conditionalExpressions [$ exprString ][$ conditionalExpression ->getKey ()] = $ conditionalExpression ;
4155+ foreach ($ typeGuards as $ guardExprString => $ guardHolder ) {
4156+ $ conditionalExpression = new ConditionalExpressionHolder ([$ guardExprString => $ guardHolder ], new ExpressionTypeHolder ($ mergedExprTypeHolder ->getExpr (), new ErrorType (), TrinaryLogic::createNo ()));
4157+ $ conditionalExpressions [$ exprString ][$ conditionalExpression ->getKey ()] = $ conditionalExpression ;
4158+ }
41574159 }
41584160
41594161 return $ conditionalExpressions ;
0 commit comments