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
Parameter with integer range in phpdoc raises error during check even with "treatPhpDocTypesAsCertain" set to false #7075
Comments
This is easy to fix. These nodes ( |
Same story, I ran into this problem: |
I made I first attempt at this. Although it works for fixing the OP issue, I still would like to do a bit more of refactoring. Let's see how it goes. |
@lcdennison After the latest push in 1.10.x, PHPStan now reports different result with your code snippet: @@ @@
-7: Comparison operation "<" between int<1, max> and 1 is always false.
+No errors |
@thg2k After the latest push in 1.10.x, PHPStan now reports different result with your code snippet: @@ @@
-5: Comparison operation ">" between int<0, 100> and 100 is always false.
+No errors |
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
Using
1.5.7
.I have
treatPhpDocTypesAsCertain: false
in my phpstan config, and that directive is working in other scenarios. However, when I apply an integer range to a parameter, and then try to check that condition (so I can throw an Exception), phpstan is saying the condition is always false. Simple example:Shouldn't this error be suppressed by
treatPhpDocTypesAsCertain
set tofalse
? Or is there some other way to handle this case?Code snippet that reproduces the problem
https://phpstan.org/r/be1acdf0-5115-40e8-b235-0fe01c94f075
Expected output
I expect no error to be raised.
The text was updated successfully, but these errors were encountered: