8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Symfony version(s) affected: v5.3.2
Description When submitting a form with square brackets after the variable name, PHP parses it into an array.
The type hint in \Symfony\Component\HttpFoundation\InputBag::get is set to:
\Symfony\Component\HttpFoundation\InputBag::get
@return string|int|float|bool|null
while the method will can also return an array.
array
How to reproduce
Require symfony/http-foundation in your composer.json
symfony/http-foundation
composer.json
Create an index.html file:
index.html
<form method="POST" action="request.php"> <input type="text" name="settings[first]"> <input type="text" name="settings[second]"> <input type="submit"> </form>
Create a request.php file:
request.php
<?php use Symfony\Component\HttpFoundation\Request; require_once __DIR__. "/vendor/autoload.php"; $r = Request::createFromGlobals(); echo "<pre>"; print_r($r->request->get("settings")); echo "</pre>";
After filling out the form with values "1" and "2" it will display:
Array ( [first] => 1 [second] => 2 )
Possible Solution The docblock could be extended to:
@return string|int|float|bool|null|array
Additional context See https://www.php.net/manual/en/faq.html.php#faq.html.arrays
I found this because Psalm gave me an error:
ERROR: InvalidArrayAccess Cannot access array value on non-array variable $r of type scalar (see https://psalm.dev/005)
The text was updated successfully, but these errors were encountered:
see #41766
Sorry, something went wrong.
Whoops my bad, will close. I must have searched for issues and not pull requests mentioning "InputBag". Thanks!
No branches or pull requests
Symfony version(s) affected: v5.3.2
Description
When submitting a form with square brackets after the variable name, PHP parses it into an array.
The type hint in
\Symfony\Component\HttpFoundation\InputBag::get
is set to:while the method will can also return an
array
.How to reproduce
Require
symfony/http-foundation
in yourcomposer.json
Create an
index.html
file:Create a
request.php
file:After filling out the form with values "1" and "2" it will display:
Possible Solution
The docblock could be extended to:
Additional context
See https://www.php.net/manual/en/faq.html.php#faq.html.arrays
I found this because Psalm gave me an error:
The text was updated successfully, but these errors were encountered: