Improve ArrayKeyExists specifyingExtension#1941
Conversation
There was a problem hiding this comment.
Jfyi we have isString() already too which I personally prefer. But it should come down to the same thing I guess. UPDATE: this was meant for the line above, sorry
221f430 to
3738bf0
Compare
|
Maybe you can add some extra tests from this old pull request? 🤔 : #636 |
9fab291 to
3738bf0
Compare
I take a look and there is only 6 check about But I can add more tests if needed |
3738bf0 to
60b3b32
Compare
There was a problem hiding this comment.
This is the same behavior than https://phpstan.org/r/5b1ebeca-e8a5-4e01-a2cb-9abda793ce4f
873b44f to
993d024
Compare
|
Just rebased the branch if you have time to review @ondrejmirtes To me the test failure are correct, cf #1941 (comment) |
08daa9d to
ed2c1f7
Compare
ed2c1f7 to
d8b729c
Compare
ondrejmirtes
left a comment
There was a problem hiding this comment.
I'd like some more tests about tricky situations. Let's say we have an array shape like:
$a = [3 => 'foo', 4 => 'bar']
When we have string $key and we ask about array_key_exists($key, $a), the $key should become '3'|'4'.
It should work generally, so int|string should become 3|4|'3'|'4'.
3bbce9b to
0d59aa1
Compare
0d59aa1 to
68c9eb3
Compare
Test added with a little fix to get the expected behavior |
|
For the build failure: The end of the foreach is indeed never reach, because of the array_key_exists check, the only https://github.com/phpstan/phpstan-src/actions/runs/3869539129/jobs/6595709711 The fact is in the doctrine code, we are inside a foreach, and we're modifying |
|
@ondrejmirtes Do I need to target 1.10.x now ? |
|
Thank you. |
Closes phpstan/phpstan#2970