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
phpstan misses "always false" when using in_array unless strict mode is enabled #4238
Comments
This is expected, it's actually "always true" situation. |
You can turn it on even without strict-rules installed: https://phpstan.org/config-reference#checkalwaystruechecktypefunctioncall |
That only seems to have an effect if the third (strict) parameter is true. PHPStan fails to find an issue in this snippet when checkAlwaysTrueCheckTypeFunctionCall is enabled, unless the third parameter is set to true. |
Yes, because loose comparison is really complicated and basically any type can equal to any type, given the right value. For example ( |
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
PHPstan doesn't notice when in_array always returns false, unless strict rules are enabled. This might be related to #2870.
Code snippet that reproduces the problem
https://phpstan.org/r/4129c443-3a90-4dd3-b5e3-2d1d2944eafe
Expected output
9 | Call to function in_array() with arguments 'first'|'second', array('first', 'second') and true will always evaluate to true.
The text was updated successfully, but these errors were encountered: