@@ -326,6 +326,26 @@ public function specifyTypesInCondition(
326326 $ context ->true () ? TypeSpecifierContext::createTruthy () : TypeSpecifierContext::createTruthy ()->negate ()
327327 );
328328 }
329+
330+ if (
331+ !$ context ->null ()
332+ && $ exprNode instanceof FuncCall
333+ && count ($ exprNode ->args ) === 1
334+ && $ exprNode ->name instanceof Name
335+ && in_array (strtolower ((string ) $ exprNode ->name ), ['count ' , 'sizeof ' ], true )
336+ && $ constantType instanceof ConstantIntegerType
337+ ) {
338+ if ($ context ->truthy () || $ constantType ->getValue () === 0 ) {
339+ $ newContext = $ context ;
340+ if ($ constantType ->getValue () === 0 ) {
341+ $ newContext = $ newContext ->negate ();
342+ }
343+ $ argType = $ scope ->getType ($ exprNode ->args [0 ]->value );
344+ if ($ argType ->isArray ()->yes ()) {
345+ return $ this ->create ($ exprNode ->args [0 ]->value , new NonEmptyArrayType (), $ newContext , false , $ scope );
346+ }
347+ }
348+ }
329349 }
330350
331351 $ leftType = $ scope ->getType ($ expr ->left );
@@ -404,11 +424,11 @@ public function specifyTypesInCondition(
404424 $ expr ->left instanceof FuncCall
405425 && count ($ expr ->left ->args ) === 1
406426 && $ expr ->left ->name instanceof Name
407- && in_array (strtolower ((string ) $ expr ->left ->name ), ['count ' , 'strlen ' ], true )
427+ && in_array (strtolower ((string ) $ expr ->left ->name ), ['count ' , 'sizeof ' , ' strlen ' ], true )
408428 && (
409429 !$ expr ->right instanceof FuncCall
410430 || !$ expr ->right ->name instanceof Name
411- || !in_array (strtolower ((string ) $ expr ->right ->name ), ['count ' , 'strlen ' ], true )
431+ || !in_array (strtolower ((string ) $ expr ->right ->name ), ['count ' , 'sizeof ' , ' strlen ' ], true )
412432 )
413433 ) {
414434 $ inverseOperator = $ expr instanceof Node \Expr \BinaryOp \Smaller
@@ -429,7 +449,7 @@ public function specifyTypesInCondition(
429449 && $ expr ->right instanceof FuncCall
430450 && count ($ expr ->right ->args ) === 1
431451 && $ expr ->right ->name instanceof Name
432- && strtolower ((string ) $ expr ->right ->name ) === 'count '
452+ && in_array ( strtolower ((string ) $ expr ->right ->name ), [ 'count ' , ' sizeof ' ], true )
433453 && (new IntegerType ())->isSuperTypeOf ($ leftType )->yes ()
434454 ) {
435455 if (
0 commit comments