-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
compare of a float
against 0
should error
#6843
Comments
"always true" is only reported with strict-rules (https://phpstan.org/r/be2789f5-5ea2-40bf-97cc-0fe9ba25dee8) or this option enabled: https://phpstan.org/config-reference#checkalwaystruestrictcomparison (check other similar options around that one in the documentation) |
But an identical/equal comparison of floats with anything is always problematic, right? Does it make sense to report this in a rule? I guess the only correct thing to do is smth like |
There's an old PR about this with some discussion: phpstan/phpstan-strict-rules#38 |
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. |
Bug report
see https://3v4l.org/Nlt7t
related issue thecodingmachine/safe#286
Code snippet that reproduces the problem
https://phpstan.org/r/b2a1e65b-14ad-43de-82c3-4219635bce90
Expected output
error, because comparison of a float against int-0 always leads to true/false
atm we see only a single error
The text was updated successfully, but these errors were encountered: