Skip to content

Commit a3ac5f6

Browse files
GromNaNnicolas-grekas
authored andcommitted
[HttpFoundation] Remove deprecated classes, method and behaviors
1 parent fab4d9f commit a3ac5f6

11 files changed

+41
-633
lines changed

CHANGELOG.md

Lines 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

ExpressionRequestMatcher.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

InputBag.php

Lines 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
}

ParameterBag.php

Lines 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
/**

Request.php

Lines 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
*

RequestMatcher.php

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)