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

Using array_map() produces an unexpected result with array_search() #3789

rvdsteege opened this issue Aug 26, 2020 · 1 comment · Fixed by phpstan/phpstan-src#1806


Copy link

Bug report

Using array_map() produces an unexpected result with array_search():

Strict comparison using === between false and 0|1|2 will always evaluate to false.

However, array_search() can also return false (

Returns the key for needle if it is found in the array, FALSE otherwise.

For now, I've added /** @var array<int, string> $supported */ before the $supported declaration as an workaround.

Code snippet that reproduces the problem

Works »

Doesn't work »

Expected output

Expected no errors with the code snippet that reproduces the problem.

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 Jan 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

2 participants