-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Bug report
I have a function that takes a bunch of named arguments (php 8.0+), and one of its callers uses conditionals to build an array that will be used to call the function.
PHPStan wrongly says "Parameter #1 $z of function foo expects ZZ|null, int|string given.", but the actual code only generates named arguments, there is never a "parameter #1".
Frankly I'm quite amazed that PHPStan gets as far as it does with this, so I'd be ready to just consider it too dynamic for static analysis, stick in a @phpstan-ignore-line and call it a day. For what it's worth, if I remove line 8 (the one with if($x)), PHPStan is actually able to validate the code, which makes me think that it's not far from being able to handle this example.
Code snippet that reproduces the problem
https://phpstan.org/r/4d448372-e178-45cb-a125-284edc0f1911
Expected output
Should not report it a bug, or at least report something more general but accurate, such as "unable to validate parameter names/types in call to function foo".
Did PHPStan help you today? Did it make you happy in any way?
Yes! I've been running it with increasing levels through some 10k lines of fairly modern code, and it has helped me fix a few minor bugs and tighten some interfaces. Thanks :)