Skip to content

Commit eaaf227

Browse files
authored
Merge pull request #4112 from paulbalandan/request-with-method
Fix Request::withMethod()
2 parents 8f88e9c + 2fb03c4 commit eaaf227

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

system/HTTP/Request.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class Request extends Message implements MessageInterface, RequestInterface
4343
*/
4444
protected $uri;
4545

46-
//--------------------------------------------------------------------
47-
4846
/**
4947
* Constructor.
5048
*
@@ -68,8 +66,6 @@ public function __construct($config = null)
6866
}
6967
}
7068

71-
//--------------------------------------------------------------------
72-
7369
/**
7470
* Validate an IP address
7571
*
@@ -85,8 +81,6 @@ public function isValidIP(string $ip = null, string $which = null): bool
8581
return (new FormatRules())->valid_ip($ip, $which);
8682
}
8783

88-
//--------------------------------------------------------------------
89-
9084
/**
9185
* Get the request method.
9286
*
@@ -101,8 +95,6 @@ public function getMethod(bool $upper = false): string
10195
return ($upper) ? strtoupper($this->method) : strtolower($this->method);
10296
}
10397

104-
//--------------------------------------------------------------------
105-
10698
/**
10799
* Sets the request method. Used when spoofing the request.
108100
*
@@ -124,16 +116,16 @@ public function setMethod(string $method)
124116
*
125117
* @param string $method
126118
*
127-
* @return self
119+
* @return static
128120
*/
129121
public function withMethod($method)
130122
{
131-
$clone = clone $this;
123+
$request = clone $this;
132124

133-
return $clone->setMethod($method);
134-
}
125+
$request->method = $method;
135126

136-
//--------------------------------------------------------------------
127+
return $request;
128+
}
137129

138130
/**
139131
* Retrieves the URI instance.

0 commit comments

Comments
 (0)