Skip to content

[HttpFoundation] Update http_foundation.rst #16980

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

Closed
wants to merge 2 commits into from

Conversation

kevinirlen
Copy link

@kevinirlen kevinirlen commented Jul 14, 2022

I believe this is not the case anymore because The get() method returns an array

When PHP imports the request query, it handles request parameters like
``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method
doesn't support returning arrays, so you need to use the following code::

From what I can see, the get() method can return arrays. See image (https://ibb.co/qB0qHKc)

Given this url contacts?foo[bar]=baz .. I can do this

    $request->query->get('foo'); // returns ['bar' => 'baz']

Tested on a symfony 4.4 application.

I believe this is not the case anymore

```
When PHP imports the request query, it handles request parameters like
``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method
doesn't support returning arrays, so you need to use the following code::
```

It's on line 165 in this http_foundation.rst.

From what I can see, the ``get()`` method can return arrays. See image (https://ibb.co/qB0qHKc)

Given this url `contacts?foo[bar]=baz` .. I can do this

```
    $request->query->get('foo'); // returns ['bar' => 'baz']

```

Tested on a symfony 4.4 application. Am I missing something?
@kevinirlen kevinirlen changed the title Update http_foundation.rst [Documentation] Update http_foundation.rst Jul 14, 2022
@kevinirlen kevinirlen changed the title [Documentation] Update http_foundation.rst [HTTP Foundation] Update http_foundation.rst Jul 14, 2022
@kevinirlen kevinirlen changed the title [HTTP Foundation] Update http_foundation.rst [HttpFoundation] Update http_foundation.rst Jul 14, 2022
@kevinirlen
Copy link
Author

more

Another test, and the $request->query->get('foo') returns what's in the picture.

@HeahDude
Copy link
Contributor

This may target 4.4, but is deprecated in 5.1 and won't work in +6.x (ref https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpFoundation/InputBag.php#L39 and symfony/symfony#34363).

@javiereguiluz
Copy link
Member

Thanks @kevinirlen ... but I'm afraid @HeahDude is right. We changed this recently and it no longer works as in previous versions. So, unless I'm missing something, I think we should close this without merging. Thanks!

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

Successfully merging this pull request may close these issues.

5 participants