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

[HttpFoundation] Remove deprecated classes, method and behaviors #50826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions 71 .github/expected-missing-return-types.diff
Original file line number Diff line number Diff line change
Expand Up @@ -7391,17 +7391,6 @@ index 71e806fc15..d60290b3ed 100644
+ public static function trustXSendfileTypeHeader(): void
{
self::$trustXSendfileTypeHeader = true;
diff --git a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
index fe65e920d9..6a78e6e779 100644
--- a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
+++ b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php
@@ -33,5 +33,5 @@ class ExpressionRequestMatcher extends RequestMatcher
* @return void
*/
- public function setExpression(ExpressionLanguage $language, Expression|string $expression)
+ public function setExpression(ExpressionLanguage $language, Expression|string $expression): void
{
$this->language = $language;
diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php
index b74a02e2e1..51b4f7f1c3 100644
--- a/src/Symfony/Component/HttpFoundation/FileBag.php
Expand Down Expand Up @@ -7621,66 +7610,6 @@ index 0bef6f8d70..ca99fd9dad 100644
+ protected static function initializeFormats(): void
{
static::$formats = [
diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
index 8c5f1d8134..fdd3a666e9 100644
--- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php
+++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php
@@ -73,5 +73,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchScheme(string|array|null $scheme)
+ public function matchScheme(string|array|null $scheme): void
{
$this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : [];
@@ -83,5 +83,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchHost(?string $regexp)
+ public function matchHost(?string $regexp): void
{
$this->host = $regexp;
@@ -95,5 +95,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchPort(?int $port)
+ public function matchPort(?int $port): void
{
$this->port = $port;
@@ -105,5 +105,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchPath(?string $regexp)
+ public function matchPath(?string $regexp): void
{
$this->path = $regexp;
@@ -117,5 +117,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchIp(string $ip)
+ public function matchIp(string $ip): void
{
$this->matchIps($ip);
@@ -129,5 +129,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchIps(string|array|null $ips)
+ public function matchIps(string|array|null $ips): void
{
$ips = null !== $ips ? (array) $ips : [];
@@ -143,5 +143,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchMethod(string|array|null $method)
+ public function matchMethod(string|array|null $method): void
{
$this->methods = null !== $method ? array_map('strtoupper', (array) $method) : [];
@@ -153,5 +153,5 @@ class RequestMatcher implements RequestMatcherInterface
* @return void
*/
- public function matchAttribute(string $key, string $regexp)
+ public function matchAttribute(string $key, string $regexp): void
{
$this->attributes[$key] = $regexp;
diff --git a/src/Symfony/Component/HttpFoundation/RequestStack.php b/src/Symfony/Component/HttpFoundation/RequestStack.php
index 5aa8ba7934..80742b0764 100644
--- a/src/Symfony/Component/HttpFoundation/RequestStack.php
Expand Down
13 changes: 13 additions & 0 deletions 13 UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ DoctrineBridge
* DoctrineBridge now requires `doctrine/event-manager:^2`
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`

HttpFoundation
--------------

* Calling `ParameterBag::filter()` on an invalid value throws an `UnexpectedValueException` instead of returning `false`.
The exception is more specific for `InputBag` which throws a `BadRequestException` when invalid value is found.
The flag `FILTER_NULL_ON_FAILURE` can be used to return `null` instead of throwing an exception.
* The methods `ParameterBag::getInt()` and `ParameterBag::getBool()` no longer fallback to `0` or `false`
when the value cannot be converted to the expected type. They throw a `UnexpectedValueException` instead.
* Replace `RequestMatcher` with `ChainRequestMatcher`
* Replace `ExpressionRequestMatcher` with `RequestMatcher\ExpressionRequestMatcher`
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI

Lock
----

Expand Down
9 changes: 9 additions & 0 deletions 9 src/Symfony/Component/HttpFoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
CHANGELOG
=========

7.0
---

* Calling `ParameterBag::filter()` throws an `UnexpectedValueException` on invalid value, unless flag `FILTER_NULL_ON_FAILURE` is set
* Calling `ParameterBag::getInt()` and `ParameterBag::getBool()` throws an `UnexpectedValueException` on invalid value
* Remove classes `RequestMatcher` and `ExpressionRequestMatcher`
* Remove `Request::getContentType()`, use `Request::getContentTypeFormat()` instead
* Throw an `InvalidArgumentException` when calling `Request::create()` with a malformed URI

6.4
---

Expand Down
56 changes: 0 additions & 56 deletions 56 src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php

This file was deleted.

8 changes: 1 addition & 7 deletions 8 src/Symfony/Component/HttpFoundation/InputBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ public function filter(string $key, mixed $default = null, int $filter = \FILTER
return $value;
}

$method = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
$method = ($method['object'] ?? null) === $this ? $method['function'] : 'filter';
$hint = 'filter' === $method ? 'pass' : 'use method "filter()" with';

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);

return false;
throw new BadRequestException(sprintf('Input value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the message a bit to hint about the flag.

}
11 changes: 2 additions & 9 deletions 11 src/Symfony/Component/HttpFoundation/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ public function getString(string $key, string $default = ''): string
*/
public function getInt(string $key, int $default = 0): int
{
// In 7.0 remove the fallback to 0, in case of failure an exception will be thrown
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]) ?: 0;
return $this->filter($key, $default, \FILTER_VALIDATE_INT, ['flags' => \FILTER_REQUIRE_SCALAR]);
}

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

$method = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
$method = ($method['object'] ?? null) === $this ? $method['function'] : 'filter';
$hint = 'filter' === $method ? 'pass' : 'use method "filter()" with';

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);
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved

return false;
throw new \UnexpectedValueException(sprintf('Parameter value "%s" is invalid and flag "FILTER_NULL_ON_FAILURE" was not set.', $key));
}

/**
Expand Down
15 changes: 1 addition & 14 deletions 15 src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ public static function create(string $uri, string $method = 'GET', array $parame

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

/**
* Gets the usual name of the format associated with the request's media type (provided in the Content-Type header).
*
* @deprecated since Symfony 6.2, use getContentTypeFormat() instead
*/
public function getContentType(): ?string
{
trigger_deprecation('symfony/http-foundation', '6.2', 'The "%s()" method is deprecated, use "getContentTypeFormat()" instead.', __METHOD__);

return $this->getContentTypeFormat();
}

/**
* Gets the usual name of the format associated with the request's media type (provided in the Content-Type header).
*
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.