Commit 85575db
committed
[TypeInfo] ArrayShape can resolve key type as callable instead of string
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.1 parent 7f69f34 commit 85575db
File tree
2 files changed
+11
-1
lines changed- src/Symfony/Component/TypeInfo
- Tests
- Type
2 files changed
+11
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
229 | 235 | | |
230 | 236 | | |
231 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
0 commit comments