Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b7fc8c2

Browse filesBrowse files
feature #50826 [HttpFoundation] Remove deprecated classes, method and behaviors (GromNaN)
This PR was squashed before being merged into the 7.0 branch. Discussion ---------- [HttpFoundation] Remove deprecated classes, method and behaviors | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | n/a Clean `symfony/http-foundation` from all its legacy. - Remove `RequestMatcher` and `ExpressionRequestMatcher`, deprecated since #47595 - Remove `Request::getContentType()`, deprecated since #45034 - Throw a `UnexpectedValueException` or `BadRequestException` when `ParameterBag::filter()` or `InputBag::filter()` reads an invalid value and the flag `FILTER_NULL_ON_FAILURE` is not set. new behavior announced since #48525 - Throw a `InvalidArgumentException` when calling `Request::create()` with a malformed URI, deprecated since #49376 Commits ------- 665a775 [HttpFoundation] Remove deprecated classes, method and behaviors
2 parents 0fdf5eb + 665a775 commit b7fc8c2
Copy full SHA for b7fc8c2

13 files changed

+54
-704
lines changed

‎.github/expected-missing-return-types.diff

Copy file name to clipboardExpand all lines: .github/expected-missing-return-types.diff
-71Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7359,17 +7359,6 @@ index 71e806fc15..d60290b3ed 100644
73597359
+ public static function trustXSendfileTypeHeader(): void
73607360
{
73617361
self::$trustXSendfileTypeHeader = true;
7362-
diff --git a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7363-
index fe65e920d9..6a78e6e779 100644
7364-
--- a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7365-
+++ b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7366-
@@ -33,5 +33,5 @@ class ExpressionRequestMatcher extends RequestMatcher
7367-
* @return void
7368-
*/
7369-
- public function setExpression(ExpressionLanguage $language, Expression|string $expression)
7370-
+ public function setExpression(ExpressionLanguage $language, Expression|string $expression): void
7371-
{
7372-
$this->language = $language;
73737362
diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php
73747363
index b74a02e2e1..51b4f7f1c3 100644
73757364
--- a/src/Symfony/Component/HttpFoundation/FileBag.php
@@ -7589,66 +7578,6 @@ index 0bef6f8d70..ca99fd9dad 100644
75897578
+ protected static function initializeFormats(): void
75907579
{
75917580
static::$formats = [
7592-
diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7593-
index 8c5f1d8134..fdd3a666e9 100644
7594-
--- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7595-
+++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7596-
@@ -73,5 +73,5 @@ class RequestMatcher implements RequestMatcherInterface
7597-
* @return void
7598-
*/
7599-
- public function matchScheme(string|array|null $scheme)
7600-
+ public function matchScheme(string|array|null $scheme): void
7601-
{
7602-
$this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : [];
7603-
@@ -83,5 +83,5 @@ class RequestMatcher implements RequestMatcherInterface
7604-
* @return void
7605-
*/
7606-
- public function matchHost(?string $regexp)
7607-
+ public function matchHost(?string $regexp): void
7608-
{
7609-
$this->host = $regexp;
7610-
@@ -95,5 +95,5 @@ class RequestMatcher implements RequestMatcherInterface
7611-
* @return void
7612-
*/
7613-
- public function matchPort(?int $port)
7614-
+ public function matchPort(?int $port): void
7615-
{
7616-
$this->port = $port;
7617-
@@ -105,5 +105,5 @@ class RequestMatcher implements RequestMatcherInterface
7618-
* @return void
7619-
*/
7620-
- public function matchPath(?string $regexp)
7621-
+ public function matchPath(?string $regexp): void
7622-
{
7623-
$this->path = $regexp;
7624-
@@ -117,5 +117,5 @@ class RequestMatcher implements RequestMatcherInterface
7625-
* @return void
7626-
*/
7627-
- public function matchIp(string $ip)
7628-
+ public function matchIp(string $ip): void
7629-
{
7630-
$this->matchIps($ip);
7631-
@@ -129,5 +129,5 @@ class RequestMatcher implements RequestMatcherInterface
7632-
* @return void
7633-
*/
7634-
- public function matchIps(string|array|null $ips)
7635-
+ public function matchIps(string|array|null $ips): void
7636-
{
7637-
$ips = null !== $ips ? (array) $ips : [];
7638-
@@ -143,5 +143,5 @@ class RequestMatcher implements RequestMatcherInterface
7639-
* @return void
7640-
*/
7641-
- public function matchMethod(string|array|null $method)
7642-
+ public function matchMethod(string|array|null $method): void
7643-
{
7644-
$this->methods = null !== $method ? array_map('strtoupper', (array) $method) : [];
7645-
@@ -153,5 +153,5 @@ class RequestMatcher implements RequestMatcherInterface
7646-
* @return void
7647-
*/
7648-
- public function matchAttribute(string $key, string $regexp)
7649-
+ public function matchAttribute(string $key, string $regexp): void
7650-
{
7651-
$this->attributes[$key] = $regexp;
76527581
diff --git a/src/Symfony/Component/HttpFoundation/RequestStack.php b/src/Symfony/Component/HttpFoundation/RequestStack.php
76537582
index 5aa8ba7934..80742b0764 100644
76547583
--- a/src/Symfony/Component/HttpFoundation/RequestStack.php

‎UPGRADE-7.0.md

Copy file name to clipboardExpand all lines: UPGRADE-7.0.md
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ DoctrineBridge
4242
* DoctrineBridge now requires `doctrine/event-manager:^2`
4343
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`
4444

45+
HttpFoundation
46+
--------------
47+
48+
* Calling `ParameterBag::filter()` on an invalid value throws an `UnexpectedValueException` instead of returning `false`.
49+
The exception is more specific for `InputBag` which throws a `BadRequestException` when invalid value is found.
50+
The flag `FILTER_NULL_ON_FAILURE` can be used to return `null` instead of throwing an exception.
51+
* The methods `ParameterBag::getInt()` and `ParameterBag::getBool()` no longer fallback to `0` or `false`
52+
when the value cannot be converted to the expected type. They throw a `UnexpectedValueException` instead.
53+
* Replace `RequestMatcher` with `ChainRequestMatcher`
54+
* Replace `ExpressionRequestMatcher` with `RequestMatcher\ExpressionRequestMatcher`
55+
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
56+
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
57+
4558
Lock
4659
----
4760

‎src/Symfony/Component/HttpFoundation/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
CHANGELOG
22
=========
33

4+
7.0
5+
---
6+
7+
* Calling `ParameterBag::filter()` throws an `UnexpectedValueException` on invalid value, unless flag `FILTER_NULL_ON_FAILURE` is set
8+
* Calling `ParameterBag::getInt()` and `ParameterBag::getBool()` throws an `UnexpectedValueException` on invalid value
9+
* Remove classes `RequestMatcher` and `ExpressionRequestMatcher`
10+
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
11+
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
12+
413
6.4
514
---
615

‎src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
-56Lines changed: 0 additions & 56 deletions
This file was deleted.

‎src/Symfony/Component/HttpFoundation/InputBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/InputBag.php
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ public function filter(string $key, mixed $default = null, int $filter = \FILTER
128128
return $value;
129129
}
130130

131-
$method = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
132-
$method = ($method['object'] ?? null) === $this ? $method['function'] : 'filter';
133-
$hint = 'filter' === $method ? 'pass' : 'use method "filter()" with';
134-
135-
trigger_deprecation('symfony/http-foundation', '6.3', 'Ignoring invalid values when using "%s::%s(\'%s\')" is deprecated and will throw a "%s" in 7.0; '.$hint.' flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', $this::class, $method, $key, BadRequestException::class);
136-
137-
return false;
131+
throw new BadRequestException(sprintf('Input value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
138132
}
139133
}

‎src/Symfony/Component/HttpFoundation/ParameterBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/ParameterBag.php
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ public function getString(string $key, string $default = ''): string
151151
*/
152152
public function getInt(string $key, int $default = 0): int
153153
{
154-
// In 7.0 remove the fallback to 0, in case of failure an exception will be thrown
155-
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]) ?: 0;
154+
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]);
156155
}
157156

158157
/**
@@ -228,13 +227,7 @@ public function filter(string $key, mixed $default = null, int $filter = \FILTER
228227
return $value;
229228
}
230229

231-
$method = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
232-
$method = ($method['object'] ?? null) === $this ? $method['function'] : 'filter';
233-
$hint = 'filter' === $method ? 'pass' : 'use method "filter()" with';
234-
235-
trigger_deprecation('symfony/http-foundation', '6.3', 'Ignoring invalid values when using "%s::%s(\'%s\')" is deprecated and will throw an "%s" in 7.0; '.$hint.' flag "FILTER_NULL_ON_FAILURE" to keep ignoring them.', $this::class, $method, $key, \UnexpectedValueException::class);
236-
237-
return false;
230+
throw new \UnexpectedValueException(sprintf('Parameter value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
238231
}
239232

240233
/**

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+1-14Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ public static function create(string $uri, string $method = 'GET', array $parame
345345

346346
$components = parse_url($uri);
347347
if (false === $components) {
348-
trigger_deprecation('symfony/http-foundation', '6.3', 'Calling "%s()" with an invalid URI is deprecated.', __METHOD__);
349-
$components = [];
348+
throw new \InvalidArgumentException(sprintf('Malformed URI "%s".', $uri));
350349
}
351350
if (isset($components['host'])) {
352351
$server['SERVER_NAME'] = $components['host'];
@@ -1337,18 +1336,6 @@ public function setRequestFormat(?string $format)
13371336
$this->format = $format;
13381337
}
13391338

1340-
/**
1341-
* Gets the usual name of the format associated with the request's media type (provided in the Content-Type header).
1342-
*
1343-
* @deprecated since Symfony 6.2, use getContentTypeFormat() instead
1344-
*/
1345-
public function getContentType(): ?string
1346-
{
1347-
trigger_deprecation('symfony/http-foundation', '6.2', 'The "%s()" method is deprecated, use "getContentTypeFormat()" instead.', __METHOD__);
1348-
1349-
return $this->getContentTypeFormat();
1350-
}
1351-
13521339
/**
13531340
* Gets the usual name of the format associated with the request's media type (provided in the Content-Type header).
13541341
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.