8000 bug #34167 [HttpFoundation] Allow to not pass a parameter to Request:… · symfony/symfony@2326f28 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2326f28

Browse files
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 (api-platform/core#3009) Commits ------- e819256 [HttpFoundation] Allow to not pass a parameter to Request::isMethodSafe()
2 parents ee4b99f + e819256 commit 2326f28

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,14 +1447,11 @@ public function isMethod($method)
14471447
*
14481448
* @see https://tools.ietf.org/html/rfc7231#section-4.2.1
14491449
*
1450-
* @param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default.
1451-
*
14521450
* @return bool
14531451
*/
1454-
public function isMethodSafe(/* $andCacheable = true */)
1452+
public function isMethodSafe()
14551453
{
1456-
if (!\func_num_args() || func_get_arg(0)) {
1457-
// setting $andCacheable to false should be deprecated in 4.1
1454+
if (\func_num_args() > 0 && func_get_arg(0)) {
14581455
throw new \BadMethodCallException('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is not supported.');
14591456
}
14601457

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ public function testMethodSafeChecksCacheable()
21322132
$this->expectException('BadMethodCallException');
21332133
$request = new Request();
21342134
$request->setMethod('OPTIONS');
2135-
$request->isMethodSafe();
2135+
$request->isMethodSafe(true);
21362136
}
21372137

21382138
/**

0 commit comments

Comments
 (0)
0