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
Improved Enum support with regard to comparisons #7052
Comments
Wow, check how easy this was :) phpstan/phpstan-src@f7d80d6 As for the other situations, one of them is covered by strict-rules (or enabling https://phpstan.org/config-reference#checkalwaystruestrictcomparison): https://phpstan.org/r/01b303cf-85b5-48fb-a3b7-06b814595682 The loose comparison |
We should probably do the same thing for all objects, only some of them can be compared with |
Cool, thanks!
Ahh I didn't realize, will make sure to add strict rules on monolog repo 👍🏻
I'd argue it should be doable for specific cases where the types are known and the same on left/right, but up to you. I added it mostly for completeness. |
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. |
Feature request
I am in the process of converting existing code to use enums in Monolog, and I noticed that PHPStan wasn't being as helpful as it could be.
See https://phpstan.org/r/920189df-c1f3-4b59-a816-02b8369fb16f for some expected errors which are missing.
See also https://3v4l.org/I2MUn#v8.1.5 for actual output.
The TL;DR is that when you have code like
if ($foo < $bar)
and then you convert it to enums and suddenly$foo
and$bar
are enum cases instead ofint
values, your code breaks but PHPStan does not tell you that this will now always return false.The text was updated successfully, but these errors were encountered: