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 array_search() type under certain conditions #7809
Comments
the return type extension for array_search looks quite complicated, I think it can be refactored and cleaned up bit. irregardless, it looks like null is returned in pre PHP 8 if the second argument is not an array for example https://3v4l.org/8nMtV. but there are a couple of old tests for that already. it should no be returned in your case though, I agree. |
I was not aware of the possibility of null being returned in PHP 7.4. Thanks. You might want to handle this based on the value of the |
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
Passing the
$strict
argument ofarray_search()
from a function reports the possibility of null being returned.Code snippet that reproduces the problem
https://phpstan.org/r/063ed345-07db-45c1-8b05-0fee820294cd
Expected output
array_search()
will never returnnull
in any case.Did PHPStan help you today? Did it make you happy in any way?
Thanks to PHPStan, various bugs have been prevented. Awesome!
The text was updated successfully, but these errors were encountered: