-
-
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
is_array() type specification not working on variable declared in condition #3446
Comments
Yeah, these styles of conditions are problematic. Use much more readable: https://phpstan.org/r/f2ed55be-f53f-4957-ac31-d01ad3c052f2 |
@dktapps After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-No errors
+15: Parameter #1 $s of method HelloWorld::takesString() expects string, array given. Full report
|
Fixed: phpstan/phpstan-src@b2bf703 |
Closes phpstan/phpstan#4761 Closes phpstan/phpstan#3331 Closes phpstan/phpstan#3106 Closes phpstan/phpstan#2640 Closes phpstan/phpstan#2413 Closes phpstan/phpstan#3446
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
It's hard to concisely describe this problem. The code can better explain.
Code snippet that reproduces the problem
https://phpstan.org/r/795b5a8b-9f34-438a-af37-14977d111516
Expected output
An error should be reported on L15 because I'm passing an array to a function which accepts
string
.When
checkExplicitMixed
is set totrue
, both L14 and L15 complain about passingmixed
as parameter, so the type inference is clearly not working correctly here.The text was updated successfully, but these errors were encountered: