Add support for strict $filter_value of array_keys()#2117
Add support for strict $filter_value of array_keys()#2117herndlm wants to merge 3 commits intophpstan:1.10.xfrom
$filter_value of array_keys()#2117Conversation
9140453 to
ac5cccb
Compare
ac5cccb to
83e8c5c
Compare
|
This pull request has been marked as ready for review. |
There was a problem hiding this comment.
instaneceof *Type is rarely correct, and in this case it isn't :) You also need to account for mixed or bool being passed in here (so we cannot be sure if it's strict or not), so as always, isSuperTypeOf() wins :)
There was a problem hiding this comment.
adapted, I think it should be more correct now? I still exit early the same way later though
There was a problem hiding this comment.
This logic should be able to use isSuperTypeOf yes/no/maybe.
There was a problem hiding this comment.
this is an edge case I think, it does already above to skip values for no, but here (with maybe|yes remaining) I want to mark maybe|yes as optional EXCEPT they are actually the same. example: filtering with bool makes the key with value true optional (because it's a supertype), but filtering with true should not make it optional (it's still a supertype though). does that make sense? I had a couple of such things already in the past, where I'm interested in basically $foo->isSuperTypeOf($bar)->yes() && !$foo->equals($bar)
dceea49 to
5817915
Compare
|
What do you think about this one? :) |
|
it might make sense to wait if #2216 becomes available soon, then this can support loose comparison too relatively easily I hope |
1489714 to
9f0a15f
Compare
9f0a15f to
0331038
Compare
|
Superseded by #3066 |
Closes phpstan/phpstan#3300