Skip to content
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

Missing array as an available return type for InputBag::get() #357

Closed
Steveb-p opened this issue Jun 29, 2023 · 2 comments
Closed

Missing array as an available return type for InputBag::get() #357

Steveb-p opened this issue Jun 29, 2023 · 2 comments

Comments

@Steveb-p
Copy link

Steveb-p commented Jun 29, 2023

Hi,

We have a case where we have a method:

QueryValidatorBuilder::validateFilterQueryInput(InputBag $input)

...and we expect to receive data using an URL containing the following query parameter:

?filter[CreatedAt][Value]=abc

This means that the InputBag would contain an array of arrays.

Since InputBag is generic (stub here: https://github.com/phpstan/phpstan-symfony/blob/1.2.x/stubs/Symfony/Component/HttpFoundation/InputBag.stub) we of course receive an analysis error that we need to define what types of data we expect InputBag to contain.
However, we cannot specify an array, since it is not declared in the allowed data types for that generic.

Is there any way we could circumvent this issue, other than of course putting it into baseline? Is it maybe possible to drop the scalar data type completely?

@ondrejmirtes
Copy link
Member

Hi, it's impossible to receive an array from InputBag because it's guarded by a native return type: https://github.com/symfony/http-foundation/blob/e0ad0d153e1c20069250986cd9e9dd1ccebb0d66/InputBag.php#L28

Maybe it's not the case in your Symfony version but it would definitely be a problem for you in the future so you need to rethink your approach anyway :)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants