1616
1717use function gettype ;
1818use function get_class ;
19- use function in_array ;
2019use function is_object ;
2120use function is_string ;
2221use function preg_match ;
2322use 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
0 commit comments