@@ -285,7 +285,7 @@ public function specifyTypesInCondition(
285
285
$ sizeType = IntegerRangeType::createAllGreaterThan ($ leftType ->getValue ());
286
286
}
287
287
} elseif ($ leftType instanceof IntegerRangeType) {
288
- $ sizeType = $ leftType ;
288
+ $ sizeType = $ leftType-> shift ( $ offset ) ;
289
289
}
290
290
291
291
$ specifiedTypes = $ this ->specifyTypesForCountFuncCall ($ expr ->right , $ argType , $ sizeType , $ context , $ scope , $ rootExpr );
@@ -1025,23 +1025,14 @@ private function specifyTypesForCountFuncCall(FuncCall $countFuncCall, Type $typ
1025
1025
1026
1026
$ arraySize = $ type ->getArraySize ();
1027
1027
$ 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 ();
1037
1030
}
1038
- if ($ context ->falsey ()) {
1039
- if (!$ isSize ->yes ()) {
1040
- return new NeverType ();
1041
- }
1031
+ if ($ context ->falsey () && !$ isSize ->yes ()) {
1032
+ return new NeverType ();
1042
1033
}
1043
1034
1044
- return $ type ;
1035
+ return $ this -> turnListIntoConstantArray ( $ type , $ sizeType ) ?? $ type ;
1045
1036
});
1046
1037
1047
1038
return $ this ->create ($ countFuncCall ->getArgs ()[0 ]->value , $ resultType , $ context , false , $ scope , $ rootExpr );
0 commit comments