Skip to content

[Http-foundation] ParameterBag typehints are incorrect #60411

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

Open
nreynis opened this issue May 13, 2025 · 0 comments
Open

[Http-foundation] ParameterBag typehints are incorrect #60411

nreynis opened this issue May 13, 2025 · 0 comments

Comments

@nreynis
Copy link

nreynis commented May 13, 2025

Symfony version(s) affected

5.4 up to 7.x

Description

ParameterBag is documented to have string keys. This is incorrect, in practice the key type is string|int.
This is due to the fact that the PHP runtime will cast any numeric-string used as an array key to a real integer.

How to reproduce

Parse a request with numeric parameter names in the query string (ie: https://domain.tld/search?0=value&78=something). The query parameter bag will have integers in its keys.

Possible Solution

The typehint should be \IteratorAggregate<string|int, mixed> (same thing for the getIterator() method).

Or the component should enforce the key type in the method keys() and getIterator(), but this is potentially a breaking change.

Additional Context

This is related to: phpstan/phpstan-symfony#439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants