From 2fb03c4fa5025bd2539339e61731a88f43c117fe Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sat, 16 Jan 2021 23:16:59 +0800 Subject: [PATCH] Fix Request::withMethod() --- system/HTTP/Request.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index f0bfb02c1d72..9b4c16df877e 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -43,8 +43,6 @@ class Request extends Message implements MessageInterface, RequestInterface */ protected $uri; - //-------------------------------------------------------------------- - /** * Constructor. * @@ -68,8 +66,6 @@ public function __construct($config = null) } } - //-------------------------------------------------------------------- - /** * Validate an IP address * @@ -85,8 +81,6 @@ public function isValidIP(string $ip = null, string $which = null): bool return (new FormatRules())->valid_ip($ip, $which); } - //-------------------------------------------------------------------- - /** * Get the request method. * @@ -101,8 +95,6 @@ public function getMethod(bool $upper = false): string return ($upper) ? strtoupper($this->method) : strtolower($this->method); } - //-------------------------------------------------------------------- - /** * Sets the request method. Used when spoofing the request. * @@ -124,16 +116,16 @@ public function setMethod(string $method) * * @param string $method * - * @return self + * @return static */ public function withMethod($method) { - $clone = clone $this; + $request = clone $this; - return $clone->setMethod($method); - } + $request->method = $method; - //-------------------------------------------------------------------- + return $request; + } /** * Retrieves the URI instance.