Skip to content

Commit 73463e3

Browse files
committed
Remove auto uppercase to RequestTrait::setMethod()
1 parent 47b6d56 commit 73463e3

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/RequestTrait.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616

1717
use function gettype;
1818
use function get_class;
19-
use function in_array;
2019
use function is_object;
2120
use function is_string;
2221
use function preg_match;
2322
use function sprintf;
24-
use function strtoupper;
2523

2624
/**
2725
* Trait implementing the methods defined in `Psr\Http\Message\RequestInterface`.
@@ -47,22 +45,6 @@ trait RequestTrait
4745
*/
4846
private UriInterface $uri;
4947

50-
/**
51-
* @var array
52-
*/
53-
private array $methods = [
54-
RequestMethodInterface::METHOD_HEAD,
55-
RequestMethodInterface::METHOD_GET,
56-
RequestMethodInterface::METHOD_POST,
57-
RequestMethodInterface::METHOD_PUT,
58-
RequestMethodInterface::METHOD_PATCH,
59-
RequestMethodInterface::METHOD_DELETE,
60-
RequestMethodInterface::METHOD_PURGE,
61-
RequestMethodInterface::METHOD_OPTIONS,
62-
RequestMethodInterface::METHOD_TRACE,
63-
RequestMethodInterface::METHOD_CONNECT,
64-
];
65-
6648
/**
6749
* Retrieves the message's request target.
6850
*
@@ -267,9 +249,7 @@ private function init(
267249
*/
268250
private function setMethod(string $method): void
269251
{
270-
$method = strtoupper($method);
271-
272-
if (!in_array($method, $this->methods) && !preg_match('/^[!#$%&\'*+.^_`|~0-9a-z-]+$/i', $method)) {
252+
if (!preg_match('/^[!#$%&\'*+.^_`|~0-9a-z-]+$/i', $method)) {
273253
throw new InvalidArgumentException(sprintf('`%s` is not valid HTTP method.', $method));
274254
}
275255

tests/RequestTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public function testWithMethod(): void
7373
$request = $this->request->withMethod(Request::METHOD_POST);
7474
self::assertNotEquals($this->request, $request);
7575
self::assertEquals(Request::METHOD_POST, $request->getMethod());
76+
77+
$request = $this->request->withMethod($method = 'PoSt');
78+
self::assertNotEquals($this->request, $request);
79+
self::assertEquals($method, $request->getMethod());
7680
}
7781

7882
public function testWithMethodHasNotBeenChangedNotClone(): void

0 commit comments

Comments
 (0)