Skip to content

Conversation

@Dean151
Copy link
Contributor

@Dean151 Dean151 commented Oct 3, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues N/A
License MIT

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.

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "7.4" but it seems your PR description refers to branch "7.3".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot carsonbot added this to the 7.4 milestone Oct 3, 2025
@Dean151 Dean151 force-pushed the callable-array-shape-key branch from 025c55b to 5f11c35 Compare October 3, 2025 12:11
@Dean151 Dean151 changed the base branch from 7.4 to 7.3 October 3, 2025 12:15
@Dean151 Dean151 force-pushed the callable-array-shape-key branch from 5f11c35 to 7dd5b1a Compare October 3, 2025 12:51
@Dean151 Dean151 force-pushed the callable-array-shape-key branch from 7dd5b1a to 85575db Compare October 3, 2025 13:33
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.
@Dean151 Dean151 force-pushed the callable-array-shape-key branch from 85575db to 5b9d547 Compare October 3, 2025 13:34
@Dean151 Dean151 requested review from GromNaN and stof October 3, 2025 13:35
Copy link
Contributor

@mtarld mtarld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@Dean151
Copy link
Contributor Author

Dean151 commented Oct 3, 2025

Nice catch!

Yeah, the kind of thing you run into when you get a weird problem!
Depending on the context, my UT were passing … or failing, because the global function was not always available.

Can someone fix the milestone? It was wrongly assigned to 7.4 instead of 7.3, because I messed up the PR opening ^^'

Thanks!

@stof stof modified the milestones: 7.4, 7.3 Oct 3, 2025
@fabpot
Copy link
Member

fabpot commented Oct 4, 2025

Thank you @Dean151.

@fabpot fabpot merged commit fa57daf into symfony:7.3 Oct 4, 2025
4 of 11 checks passed
@fabpot fabpot mentioned this pull request Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants