Skip to content

Commit 22f0140

Browse files
committed
minor #15847 [HttpFoundation] Document the removal of array support in get() (javiereguiluz)
This PR was squashed before being merged into the 5.3 branch. Discussion ---------- [HttpFoundation] Document the removal of array support in get() Fixes #15613. Commits ------- fcf41a0 [HttpFoundation] Document the removal of array support in get()
2 parents 9dc48bf + fcf41a0 commit 22f0140

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

components/http_foundation.rst

+9-4
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+
// don't use $request->query->get('foo'); use the following instead:
172+
$request->query->all()['foo'];
172173
// returns ['bar' => 'baz']
173174

174175
$request->query->get('foo[bar]');
175176
// returns null
176177

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

181+
.. deprecated:: 5.1
182+
183+
The array support in ``get()`` method was deprecated in 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)