DynamicReturnType for array search call not strict#215
Merged
ondrejmirtes merged 2 commits intophpstan:masterfrom May 28, 2020
Merged
DynamicReturnType for array search call not strict#215ondrejmirtes merged 2 commits intophpstan:masterfrom
ondrejmirtes merged 2 commits intophpstan:masterfrom
Conversation
Member
|
This is fine. Please fix the failed build so I can merge this, thanks. |
c727093 to
ff160ef
Compare
ff160ef to
1c0c8fe
Compare
Contributor
Author
|
@ondrejmirtes Fixed ! |
Member
|
Thank you :) |
Contributor
|
NULL is returned when some parameter doesnt match type. |
Contributor
Author
I didn't removed all the null return type. Only the ones I thought as wrong. |
Contributor
|
Yeah, it was just answer to your question, which I now read correctly is not question 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close phpstan/phpstan#3316
When a call
array_search($foo, $array)orarray_search($foo, $array, false)is made we can still restrict the type of the return value thanks to the type of the array keys.And I saw no reason to add
nullas a possible return value.Another thing. During writing/updating the tests, I saw
When
$generalIntegersis typed withint[].This seems weird to me. There was a check about BenevolentUnionType, I don't see any reason to keep it ; tell me if I'm wrong. So I added a fix.