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
Invalid error for float type check using 0 #1961
Comments
Just ran into this and wanted to share this case where it doesn't occur with a method coming from a trait. Maybe it's helpful.. or not.. |
Traits in playground behave in a weird way. When running locally, both occurences are reported. |
A generalized blacklist regex I use for this bug: Maybe someone else will find it useful. |
Why not using ?
|
It can be done, but when there are hundreds of places in your code where an integer literal is used, it's not very appealing to change them all because of a small bug in a static analyser. |
Fixed: phpstan/phpstan-src@a5beb06 |
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. |
Summary of a problem or a feature request
Using 0 as default parameter for float type argument gives error:
Default value of the parameter #1 xx of method nn is incompatible with type float.
Code snippet that reproduces the problem
public function test2(float $test2 = 0): void { //}
https://phpstan.org/r/83d22916-c7a8-4bc3-8d37-27b361326329
Expected output
No error
The text was updated successfully, but these errors were encountered: