Skip to content
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

Incorrect NarrowedType detection on in_array(null) and bool value #12755

Open
delamotte-pierrick opened this issue Mar 19, 2025 · 0 comments · May be fixed by phpstan/phpstan-src#3888
Open

Incorrect NarrowedType detection on in_array(null) and bool value #12755

delamotte-pierrick opened this issue Mar 19, 2025 · 0 comments · May be fixed by phpstan/phpstan-src#3888
Labels
Milestone

Comments

@delamotte-pierrick
Copy link

Bug report

This happend while trying to check if any value in my array is strictly equal to null (in_array(null, $array, true)) on an array having a value possibly null or boolean.

It throw an error function.alreadyNarrowedType telling that the result of the in_array is always true

It also throw an error deadCode.unreachable as a by-product

Code snippet that reproduces the problem

https://phpstan.org/r/06e26187-5d60-4337-9b1f-dfff6286bdf6

Expected output

Should not return any error

Did PHPStan help you today? Did it make you happy in any way?

Yes, helped me avoiding a lot of error in production :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants