Skip to content

Commit e7e0520

Browse files
committed
remove Request::get()
1 parent 8318e46 commit e7e0520

File tree

3 files changed

+1
-53
lines changed

3 files changed

+1
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* Add arguments `$v4Bytes` and `$v6Bytes` to `IpUtils::anonymize()`
1111
* Add argument `$partitioned` to `ResponseHeaderBag::clearCookie()`
1212
* Add argument `$expiration` to `UriSigner::sign()`
13+
* Remove `Request::get()`, use properties `->attributes`, `query` or `request` directly instead
1314

1415
7.4
1516
---

Request.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -670,36 +670,6 @@ public static function getHttpMethodParameterOverride(): bool
670670
return self::$httpMethodParameterOverride;
671671
}
672672

673-
/**
674-
* Gets a "parameter" value from any bag.
675-
*
676-
* This method is mainly useful for libraries that want to provide some flexibility. If you don't need the
677-
* flexibility in controllers, it is better to explicitly get request parameters from the appropriate
678-
* public property instead (attributes, query, request).
679-
*
680-
* Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
681-
*
682-
* @deprecated since Symfony 7.4, use properties `->attributes`, `query` or `request` directly instead
683-
*/
684-
public function get(string $key, mixed $default = null): mixed
685-
{
686-
trigger_deprecation('symfony/http-foundation', '7.4', 'Request::get() is deprecated, use properties ->attributes, query or request directly instead.');
687-
688-
if ($this !== $result = $this->attributes->get($key, $this)) {
689-
return $result;
690-
}
691-
692-
if ($this->query->has($key)) {
693-
return $this->query->all()[$key];
694-
}
695-
696-
if ($this->request->has($key)) {
697-
return $this->request->all()[$key];
698-
}
699-
700-
return $default;
701-
}
702-
703673
/**
704674
* Gets the Session.
705675
*

Tests/RequestTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\HttpFoundation\Tests;
1313

1414
use PHPUnit\Framework\Attributes\DataProvider;
15-
use PHPUnit\Framework\Attributes\Group;
16-
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1715
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1816
use PHPUnit\Framework\Attributes\TestWith;
1917
use PHPUnit\Framework\TestCase;
@@ -1510,27 +1508,6 @@ public function testGetPathInfo()
15101508
$this->assertEquals('/', $request->getPathInfo());
15111509
}
15121510

1513-
#[IgnoreDeprecations]
1514-
#[Group('legacy')]
1515-
public function testGetParameterPrecedence()
1516-
{
1517-
$request = new Request();
1518-
$request->attributes->set('foo', 'attr');
1519-
$request->query->set('foo', 'query');
1520-
$request->request->set('foo', 'body');
1521-
1522-
$this->assertSame('attr', $request->get('foo'));
1523-
1524-
$request->attributes->remove('foo');
1525-
$this->assertSame('query', $request->get('foo'));
1526-
1527-
$request->query->remove('foo');
1528-
$this->assertSame('body', $request->get('foo'));
1529-
1530-
$request->request->remove('foo');
1531-
$this->assertNull($request->get('foo'));
1532-
}
1533-
15341511
public function testGetPreferredLanguage()
15351512
{
15361513
$request = new Request();

0 commit comments

Comments
 (0)