Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Http-foundation] ParameterBag typehints are incorrect #60411

Copy link
Copy link
Open
@nreynis

Description

@nreynis
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.