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
{{ message }}
Repository navigation
Variable $ in empty() always exists and is not falsy. #14223
phpstan generates an error on the second usage of empty().
If it warns in this case, I think it should warn in both cases or none!?
It warns because one should use count($a)===0 or []===$a to check if the array $a is empty - instead of using the function empty(). But why does it warn only on second usage?
Activity
VincentLanglet commentedon Mar 3, 2026
Issue simplified to https://phpstan.org/r/08705654-4de0-4dc8-8794-0609d73d4ffd
https://github.com/phpstan/phpstan-src/blob/11e8d9db6fae7edc16b5a2460c4aea52d0583b13/src/Type/Php/ArrayCountValuesDynamicReturnTypeExtension.php#L29
need to be fixed.
Fix phpstan/phpstan#14223: array_count_values on possibly-empty array…
Fix phpstan/phpstan#14223: Variable $ in empty() always exists and is…
phpstan-bot commentedon Mar 3, 2026
Closed via merging phpstan/phpstan-src#5124
Updated PHPStan to commit 46df20fbbcb6ec10e170ba5417547d61cae0bdd0
Updated PHPStan to commit f08de4291d5174440a2e35eb10f06e3570beaf89
github-actions commentedon Apr 4, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Fix phpstan/phpstan#14223: Variable $ in empty() always exists and is…