Skip to content

Commit

Permalink
Merge pull request #4112 from paulbalandan/request-with-method
Browse files Browse the repository at this point in the history
Fix Request::withMethod()
  • Loading branch information
paulbalandan authored Jan 17, 2021
2 parents 8f88e9c + 2fb03c4 commit eaaf227
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions system/HTTP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class Request extends Message implements MessageInterface, RequestInterface
*/
protected $uri;

//--------------------------------------------------------------------

/**
* Constructor.
*
Expand All @@ -68,8 +66,6 @@ public function __construct($config = null)
}
}

//--------------------------------------------------------------------

/**
* Validate an IP address
*
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand All @@ -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.
Expand Down

0 comments on commit eaaf227

Please sign in to comment.