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

in_array cannot be used as null check #7153

Closed
petermein opened this issue Apr 29, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1430
Closed

in_array cannot be used as null check #7153

petermein opened this issue Apr 29, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1430

Comments

@petermein
Copy link

Bug report

When trying to check if an array contains any NULL values. The in_array function can be used with the strict flag set.
However PHPStan is not picking up that the values cannot be null inside of the array.

Code snippet that reproduces the problem

https://phpstan.org/r/69897217-fd94-497b-9e98-4baa6b2b96db

Expected output

The output should mention string is givin instead of string|null.

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

PHPStan is the best! We've worked around this issue with the help of Webmozart assert, but it not diminished our excitement in using PHPStan. Great job!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants