New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive for empty
on non-empty-string
#7199
Labels
Milestone
Comments
@oliverklee After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-10: Variable $string in empty() always exists and is not falsy.
+No errors |
staabm
added a commit
to staabm/phpstan-src
that referenced
this issue
Aug 6, 2022
staabm
added a commit
to staabm/phpstan-src
that referenced
this issue
Aug 6, 2022
ondrejmirtes
pushed a commit
to phpstan/phpstan-src
that referenced
this issue
Aug 6, 2022
Thanks! ❤️ |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
empty()
in PHP is evil and behaves in mysterious ways. Particularly, as it basically is a check for truthy-ness, it considers the string"0"
to be empty. That means that any variable/parameter that is anon-empty-string
can still lead toempty($var)
to beempty
as well.Code snippet that reproduces the problem
https://phpstan.org/r/5f809ad5-cee9-423c-b7aa-9ec2d432793a
Expected output
no error
Did PHPStan help you today? Did it make you happy in any way?
PHPStan still is one of my favorite gamified activities, and it helps me improve the code of my TYPO3 extensions and the TYPO3 core.
The text was updated successfully, but these errors were encountered: