Skip to content

Conversation

@takaram
Copy link
Contributor

@takaram takaram commented Oct 10, 2022

Return type of array_search() may be false unless we are sure that $haystack includes a value identical to $needle.

Closes phpstan/phpstan#3789

@takaram takaram force-pushed the array-search-return-type branch from 22fcd92 to cb14292 Compare October 12, 2022 11:37
@staabm
Copy link
Contributor

staabm commented Oct 21, 2022

//cc @herndlm this will need manual conflict resolving with #1874

@takaram takaram force-pushed the array-search-return-type branch from cb14292 to fe102f9 Compare November 5, 2022 13:06
@takaram takaram changed the base branch from 1.8.x to 1.9.x November 5, 2022 13:06
Comment on lines 11 to 19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add test-cases for the non-strict variant (leaving the 3rd param to false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added test cases.

@takaram takaram force-pushed the array-search-return-type branch from fe102f9 to cdab81a Compare November 6, 2022 13:15
@ondrejmirtes ondrejmirtes force-pushed the array-search-return-type branch from cdab81a to 980e931 Compare December 15, 2022 13:52
@ondrejmirtes ondrejmirtes merged commit b428afc into phpstan:1.9.x Dec 15, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@takaram takaram deleted the array-search-return-type branch February 24, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants