-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[TypeInfo] ArrayShape can resolve key type as callable instead of string #61943
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
Conversation
|
Hey! Thanks for your PR. You are targeting branch "7.4" but it seems your PR description refers to branch "7.3". Cheers! Carsonbot |
025c55b to
5f11c35
Compare
5f11c35 to
7dd5b1a
Compare
7dd5b1a to
85575db
Compare
In PHP, array key type is either string or int. Although callable is not entirely false as long as it's a string callable, using callable as a key type for an array seems wrong, and it's unlikely to be what we expect. This is peculiarly true in environment when key name might collide with global function name. Proposed change is to check for int/string instead of resolving type. Because the input is an array, the key is already narrowed down to string|int in the input This bugfix is also a change of behavior, as callable was likely to be fed in keyTypes, and it won't longer occur with that change.
85575db to
5b9d547
Compare
mtarld
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
Yeah, the kind of thing you run into when you get a weird problem! Can someone fix the milestone? It was wrongly assigned to 7.4 instead of 7.3, because I messed up the PR opening ^^' Thanks! |
|
Thank you @Dean151. |
In PHP, array key type is either string or int. Although callable is not entirely false as long as it's a string callable, using callable as a key type for an array seems wrong, and it's unlikely to be what we expect. This is peculiarly true in environment when key name might collide with global function name.
Proposed change is to check for int/string instead of resolving type.
Because the input is an array, the key is already narrowed down to string|int in the input
This bugfix is also a change of behavior, as callable was likely to be fed in keyTypes, and it won't longer occur with that change.