You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Symfony version(s) affected
5.4 up to 7.x
Description
ParameterBag
is documented to havestring
keys. This is incorrect, in practice the key type isstring|int
.This is due to the fact that the PHP runtime will cast any
numeric-string
used as an array key to a realinteger
.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 thegetIterator()
method).Or the component should enforce the key type in the method
keys()
andgetIterator()
, but this is potentially a breaking change.Additional Context
This is related to: phpstan/phpstan-symfony#439
The text was updated successfully, but these errors were encountered: