Skip to content

Commit 8318e46

Browse files
Merge branch '7.4' into 8.0
* 7.4: (28 commits) [Messenger] Allow Pheanstalk v8 [TypeInfo] Fix resolving constructor type with templates fix compatibility with RelayCluster 0.12 fix type alias with template resolving fix compatibility with RelayCluster 0.11 and 0.12 [DependencyInjection] Register a custom autoloader to generate `*Config` classes when they don't exist yet [Security] Add security:oidc-token:generate command [PropertyInfo][TypeInfo] Fix resolving constructor type with templates [WebProfilerBundle] ”finish” errored requests Add support for union types on AsEventListener [Console] Update CHANGELOG to reflect attribute name changes for interactive invokable commands bump ext-redis to 6.2 and ext-relay to 0.12 minimum [TypeInfo] Fix type alias with template resolving [Console] Add support for interactive invokable commands with `#[Interact]` and `#[Ask]` attributes bump ext-relay to 0.12+ fix merge [Config] Generate the array-shape of the current node instead of the whole root node in Config classes [HttpFoundation] Deprecate Request::get() in favor of using properties ->attributes, query or request directly fix Relay Cluster 0.12 compatibility [TypeInfo] ArrayShape can resolve key type as callable instead of string ...
2 parents eed5f5b + 3d9e8f1 commit 8318e46

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ CHANGELOG
1414
7.4
1515
---
1616

17-
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
1817
* Add `#[WithHttpStatus]` to define status codes: 404 for `SignedUriException` and 403 for `ExpiredSignedUriException`
1918
* Add support for the `QUERY` HTTP method
2019
* Add support for structured MIME suffix
20+
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
21+
* Deprecate method `Request::get()`, use properties `->attributes`, `query` or `request` directly instead
2122

2223
7.3
2324
---

Request.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ public function duplicate(?array $query = null, ?array $request = null, ?array $
468468
$dup->method = null;
469469
$dup->format = null;
470470

471-
if (!$dup->get('_format') && $this->get('_format')) {
472-
$dup->attributes->set('_format', $this->get('_format'));
471+
if (!$dup->attributes->has('_format') && $this->attributes->has('_format')) {
472+
$dup->attributes->set('_format', $this->attributes->get('_format'));
473473
}
474474

475475
if (!$dup->getRequestFormat(null)) {
@@ -679,10 +679,12 @@ public static function getHttpMethodParameterOverride(): bool
679679
*
680680
* Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
681681
*
682-
* @internal use explicit input sources instead
682+
* @deprecated since Symfony 7.4, use properties `->attributes`, `query` or `request` directly instead
683683
*/
684684
public function get(string $key, mixed $default = null): mixed
685685
{
686+
trigger_deprecation('symfony/http-foundation', '7.4', 'Request::get() is deprecated, use properties ->attributes, query or request directly instead.');
687+
686688
if ($this !== $result = $this->attributes->get($key, $this)) {
687689
return $result;
688690
}
@@ -1109,10 +1111,8 @@ public function getHost(): string
11091111
{
11101112
if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_X_FORWARDED_HOST)) {
11111113
$host = $host[0];
1112-
} elseif (!$host = $this->headers->get('HOST')) {
1113-
if (!$host = $this->server->get('SERVER_NAME')) {
1114-
$host = $this->server->get('SERVER_ADDR', '');
1115-
}
1114+
} else {
1115+
$host = $this->headers->get('HOST') ?: $this->server->get('SERVER_NAME') ?: $this->server->get('SERVER_ADDR', '');
11161116
}
11171117

11181118
// trim and remove port number from host

Tests/RequestTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
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;
1517
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1618
use PHPUnit\Framework\Attributes\TestWith;
1719
use PHPUnit\Framework\TestCase;
@@ -1508,6 +1510,8 @@ public function testGetPathInfo()
15081510
$this->assertEquals('/', $request->getPathInfo());
15091511
}
15101512

1513+
#[IgnoreDeprecations]
1514+
#[Group('legacy')]
15111515
public function testGetParameterPrecedence()
15121516
{
15131517
$request = new Request();

0 commit comments

Comments
 (0)