Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64ec8b4

Browse files
committed
[HttpFoundation] deprecated finding deep items in Request and ParameterBag
1 parent ce3b8fd commit 64ec8b4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Symfony/Component/HttpFoundation/ParameterBag.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ public function add(array $parameters = array())
9999
* @throws \InvalidArgumentException
100100
*
101101
* @api
102+
*
103+
* @deprecated Finding deep items is deprecated since version 2.7, to be removed in 3.0.
102104
*/
103105
public function get($path, $default = null, $deep = false)
104106
{
107+
if (true === $deep) {
108+
trigger_error('Using paths to find deeper items in '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0. Filter the returned value in your own code instead.', E_USER_DEPRECATED);
109+
}
110+
105111
if (!$deep || false === $pos = strpos($path, '[')) {
106112
return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
107113
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,15 @@ public static function getHttpMethodParameterOverride()
743743
* @param bool $deep is parameter deep in multidimensional array
744744
*
745745
* @return mixed
746+
*
747+
* @deprecated Finding deep items is deprecated since version 2.7, to be removed in 3.0.
746748
*/
747749
public function get($key, $default = null, $deep = false)
748750
{
751+
if (true === $deep) {
752+
trigger_error('Using paths to find deeper items in '.__METHOD__.' is deprecated since version 2.7 and will be removed in 3.0. Filter the returned value in your own code instead.', E_USER_DEPRECATED);
753+
}
754+
749755
if ($this !== $result = $this->query->get($key, $this, $deep)) {
750756
return $result;
751757
}

src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testGetDoesNotUseDeepByDefault()
8989
* @dataProvider getInvalidPaths
9090
* @expectedException \InvalidArgumentException
9191
*/
92-
public function testGetDeepWithInvalidPaths($path)
92+
public function testLegacyGetDeepWithInvalidPaths($path)
9393
{
9494
$bag = new ParameterBag(array('foo' => array('bar' => 'moo')));
9595

@@ -106,7 +106,7 @@ public function getInvalidPaths()
106106
);
107107
}
108108

109-
public function testGetDeep()
109+
public function testLegacyGetDeep()
110110
{
111111
$bag = new ParameterBag(array('foo' => array('bar' => array('moo' => 'boo'))));
112112

0 commit comments

Comments
 (0)