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 665a775

Browse filesBrowse files
GromNaNnicolas-grekas
authored andcommitted
[HttpFoundation] Remove deprecated classes, method and behaviors
1 parent 0132503 commit 665a775
Copy full SHA for 665a775

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
@@ -7391,17 +7391,6 @@ index 71e806fc15..d60290b3ed 100644
73917391
+ public static function trustXSendfileTypeHeader(): void
73927392
{
73937393
self::$trustXSendfileTypeHeader = true;
7394-
diff --git a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7395-
index fe65e920d9..6a78e6e779 100644
7396-
--- a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7397-
+++ b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
7398-
@@ -33,5 +33,5 @@ class ExpressionRequestMatcher extends RequestMatcher
7399-
* @return void
7400-
*/
7401-
- public function setExpression(ExpressionLanguage $language, Expression|string $expression)
7402-
+ public function setExpression(ExpressionLanguage $language, Expression|string $expression): void
7403-
{
7404-
$this->language = $language;
74057394
diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php
74067395
index b74a02e2e1..51b4f7f1c3 100644
74077396
--- a/src/Symfony/Component/HttpFoundation/FileBag.php
@@ -7621,66 +7610,6 @@ index 0bef6f8d70..ca99fd9dad 100644
76217610
+ protected static function initializeFormats(): void
76227611
{
76237612
static::$formats = [
7624-
diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7625-
index 8c5f1d8134..fdd3a666e9 100644
7626-
--- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7627-
+++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
7628-
@@ -73,5 +73,5 @@ class RequestMatcher implements RequestMatcherInterface
7629-
* @return void
7630-
*/
7631-
- public function matchScheme(string|array|null $scheme)
7632-
+ public function matchScheme(string|array|null $scheme): void
7633-
{
7634-
$this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : [];
7635-
@@ -83,5 +83,5 @@ class RequestMatcher implements RequestMatcherInterface
7636-
* @return void
7637-
*/
7638-
- public function matchHost(?string $regexp)
7639-
+ public function matchHost(?string $regexp): void
7640-
{
7641-
$this->host = $regexp;
7642-
@@ -95,5 +95,5 @@ class RequestMatcher implements RequestMatcherInterface
7643-
* @return void
7644-
*/
7645-
- public function matchPort(?int $port)
7646-
+ public function matchPort(?int $port): void
7647-
{
7648-
$this->port = $port;
7649-
@@ -105,5 +105,5 @@ class RequestMatcher implements RequestMatcherInterface
7650-
* @return void
7651-
*/
7652-
- public function matchPath(?string $regexp)
7653-
+ public function matchPath(?string $regexp): void
7654-
{
7655-
$this->path = $regexp;
7656-
@@ -117,5 +117,5 @@ class RequestMatcher implements RequestMatcherInterface
7657-
* @return void
7658-
*/
7659-
- public function matchIp(string $ip)
7660-
+ public function matchIp(string $ip): void
7661-
{
7662-
$this->matchIps($ip);
7663-
@@ -129,5 +129,5 @@ class RequestMatcher implements RequestMatcherInterface
7664-
* @return void
7665-
*/
7666-
- public function matchIps(string|array|null $ips)
7667-
+ public function matchIps(string|array|null $ips): void
7668-
{
7669-
$ips = null !== $ips ? (array) $ips : [];
7670-
@@ -143,5 +143,5 @@ class RequestMatcher implements RequestMatcherInterface
7671-
* @return void
7672-
*/
7673-
- public function matchMethod(string|array|null $method)
7674-
+ public function matchMethod(string|array|null $method): void
7675-
{
7676-
$this->methods = null !== $method ? array_map('strtoupper', (array) $method) : [];
7677-
@@ -153,5 +153,5 @@ class RequestMatcher implements RequestMatcherInterface
7678-
* @return void
7679-
*/
7680-
- public function matchAttribute(string $key, string $regexp)
7681-
+ public function matchAttribute(string $key, string $regexp): void
7682-
{
7683-
$this->attributes[$key] = $regexp;
76847613
diff --git a/src/Symfony/Component/HttpFoundation/RequestStack.php b/src/Symfony/Component/HttpFoundation/RequestStack.php
76857614
index 5aa8ba7934..80742b0764 100644
76867615
--- 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
@@ -22,6 +22,19 @@ DoctrineBridge
2222
* DoctrineBridge now requires `doctrine/event-manager:^2`
2323
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`
2424

25+
HttpFoundation
26+
--------------
27+
28+
* Calling `ParameterBag::filter()` on an invalid value throws an `UnexpectedValueException` instead of returning `false`.
29+
The exception is more specific for `InputBag` which throws a `BadRequestException` when invalid value is found.
30+
The flag `FILTER_NULL_ON_FAILURE` can be used to return `null` instead of throwing an exception.
31+
* The methods `ParameterBag::getInt()` and `ParameterBag::getBool()` no longer fallback to `0` or `false`
32+
when the value cannot be converted to the expected type. They throw a `UnexpectedValueException` instead.
33+
* Replace `RequestMatcher` with `ChainRequestMatcher`
34+
* Replace `ExpressionRequestMatcher` with `RequestMatcher\ExpressionRequestMatcher`
35+
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
36+
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI
37+
2538
Lock
2639
----
2740

‎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.