Skip to content

Commit 1db6ba2

Browse files
committed
[HttpFoundation] Document the removal of array support in get()
1 parent c8fdee6 commit 1db6ba2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

components/http_foundation.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,25 @@ exist::
163163
// returns 'baz'
164164

165165
When PHP imports the request query, it handles request parameters like
166-
``foo[bar]=baz`` in a special way as it creates an array. So you can get the
167-
``foo`` parameter and you will get back an array with a ``bar`` element::
166+
``foo[bar]=baz`` in a special way as it creates an array. The ``get()`` method
167+
doesn't support returning arrays, so you need to use the following code::
168168

169169
// the query string is '?foo[bar]=baz'
170170

171-
$request->query->get('foo');
171+
$request->query->all()['foo'];
172172
// returns ['bar' => 'baz']
173173

174174
$request->query->get('foo[bar]');
175175
// returns null
176176

177-
$request->query->get('foo')['bar'];
177+
$request->query->all()['foo']['bar'];
178178
// returns 'baz'
179179

180+
.. versionadded:: 5.1
181+
182+
The feature that removed array support in ``get()`` was introduced in
183+
Symfony 5.1.
184+
180185
.. _component-foundation-attributes:
181186

182187
Thanks to the public ``attributes`` property, you can store additional data

0 commit comments

Comments
 (0)