You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix array not narrowed to non-empty when count stored in variable
- When $count = count($a) and later $count > 1 or $count === 1,
the array $a was not narrowed to non-empty-array
- Root cause: conditional expression matching required exact type
equality, but count comparisons produce subtypes (e.g. int<2, max>
is a subtype of int<1, max>)
- Added conditionalExpressionHolderMatches() that uses isSuperTypeOf
for IntegerRangeType conditions, enabling count-based narrowing
- New regression test in tests/PHPStan/Analyser/nsrt/bug-4090.php
Closesphpstan/phpstan#4090
0 commit comments