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
Report PossiblyDivisionByZero #7584
Comments
I think this feature seems implemented already as you mentioned, report for float is not possible yet. |
I often enable the exceptions checks of phpstan, but always disable it for To me DivisionByError is in the same situation and should have his own error reported by phpstan. In the same way, TypeError is an error but phpstan reports when you're passing a possibly wrong type to a method. |
This is trivial to implement for integers: Report it if For floats it's not possible right now as we don't have FloatRangeType. |
Started in phpstan/phpstan-src#1636 |
Closed because of phpstan/phpstan-src#1636 (comment) |
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
It could be useful to have phpstan report a possibly division by zero error.
Maybe it require to be an option or a strict rule.
https://phpstan.org/r/43bf5d53-27c4-4684-81f3-8dddcd805472
It might be easier for
int
since adding a0
check is changing the value toint<min, -1>|int<1, max>
.For
float
, currently, a!== 0.0
check is not narrowing the type to something likenon-negative-float
orpositive-float|negative-float
.The text was updated successfully, but these errors were encountered: