bug #34167 [HttpFoundation] Allow to not pass a parameter to Request::isMethodSafe() (dunglas)
This PR was squashed before being merged into the 4.3 branch.
Discussion
----------
[HttpFoundation] Allow to not pass a parameter to Request::isMethodSafe()
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a
| License | MIT
| Doc PR | n/a
This parameter was already deprecated in Symfony 4. Allowing to not pass it in Symfony 4.3 without triggering a deprecation allows to support both HttpFoundation 4.3 and 4.4, otherwise it's not possible.
Needed to make API Platform compatible with Symfony 5 (https://github.com/api-platform/core/pull/3009)
Commits
-------
e819256ea0
[HttpFoundation] Allow to not pass a parameter to Request::isMethodSafe()
This commit is contained in:
commit
2326f2882c
@ -1447,14 +1447,11 @@ class Request
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7231#section-4.2.1
|
||||
*
|
||||
* @param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMethodSafe(/* $andCacheable = true */)
|
||||
public function isMethodSafe()
|
||||
{
|
||||
if (!\func_num_args() || func_get_arg(0)) {
|
||||
// setting $andCacheable to false should be deprecated in 4.1
|
||||
if (\func_num_args() > 0 && func_get_arg(0)) {
|
||||
throw new \BadMethodCallException('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is not supported.');
|
||||
}
|
||||
|
||||
|
@ -2132,7 +2132,7 @@ class RequestTest extends TestCase
|
||||
$this->expectException('BadMethodCallException');
|
||||
$request = new Request();
|
||||
$request->setMethod('OPTIONS');
|
||||
$request->isMethodSafe();
|
||||
$request->isMethodSafe(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user