@@ -285,7 +285,7 @@ public function specifyTypesInCondition(
285285 $ sizeType = IntegerRangeType::createAllGreaterThan ($ leftType ->getValue ());
286286 }
287287 } elseif ($ leftType instanceof IntegerRangeType) {
288- $ sizeType = $ leftType ;
288+ $ sizeType = $ leftType-> shift ( $ offset ) ;
289289 }
290290
291291 $ specifiedTypes = $ this ->specifyTypesForCountFuncCall ($ expr ->right , $ argType , $ sizeType , $ context , $ scope , $ rootExpr );
@@ -1025,23 +1025,14 @@ private function specifyTypesForCountFuncCall(FuncCall $countFuncCall, Type $typ
10251025
10261026 $ arraySize = $ type ->getArraySize ();
10271027 $ isSize = $ sizeType ->isSuperTypeOf ($ arraySize );
1028- if ($ context ->truthy ()) {
1029- if ($ isSize ->no ()) {
1030- return new NeverType ();
1031- }
1032-
1033- $ constArray = $ this ->turnListIntoConstantArray ($ type , $ sizeType );
1034- if ($ constArray !== null ) {
1035- $ type = $ constArray ;
1036- }
1028+ if ($ context ->truthy () && $ isSize ->no ()) {
1029+ return new NeverType ();
10371030 }
1038- if ($ context ->falsey ()) {
1039- if (!$ isSize ->yes ()) {
1040- return new NeverType ();
1041- }
1031+ if ($ context ->falsey () && !$ isSize ->yes ()) {
1032+ return new NeverType ();
10421033 }
10431034
1044- return $ type ;
1035+ return $ this -> turnListIntoConstantArray ( $ type , $ sizeType ) ?? $ type ;
10451036 });
10461037
10471038 return $ this ->create ($ countFuncCall ->getArgs ()[0 ]->value , $ resultType , $ context , false , $ scope , $ rootExpr );
0 commit comments