-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Type mismatch with literal-string is reported on higher level than others #10930
Comments
I agree these should be reported on the same level but I steer more towards level 7. My reasoning: level 5 is about types that are definitely wrong, like But The reason why is this currently inconsistent is because As I always point out in issues like these is that you should be aware that unless you're on the highest level, you're always missing out on potential errors :) Personally I feel quite safe on level 8, level 9 is too brutal for me. But level 7 will definitely show a lot of useful errors when compared to level 5. |
Bug report
Function like
/** @param int $a */ function barInt($a): void { }
must be called with int parameter. When string is given, we get error
Parameter #1 $a of function barInt expects int, string given.
on level 5.Similarly for annotated
class-string
(see linked snippet).For annotated
literal-string
there is error reported only on level 7 and higher.I understand why this is reported only with parameter
checkUnionTypes: true
but from user perspective it is as same error as sending string into class-stringCode snippet that reproduces the problem
https://phpstan.org/r/86fb5a64-e35e-4c40-9cd9-7560f2cc8d8f
Expected output
string
intoliteral-string
is as same type of error asstring
intoclass-string
so they should be reported on same level.Expected output should be: 3 errors reported on level 5.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: