Skip to content

Commit

Permalink
Merge pull request #1655 from akrabat/tidy-up-method-handling
Browse files Browse the repository at this point in the history
Tidy up method handling
  • Loading branch information
codeguy committed Dec 7, 2015
2 parents 293f839 + 45e7f5b commit 3b06f0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Slim/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ public function getMethod()
$body = $this->getParsedBody();

if (is_object($body) && property_exists($body, '_METHOD')) {
$this->method = $this->filterMethod($body->_METHOD);
$this->method = $this->filterMethod((string)$body->_METHOD);
} elseif (is_array($body) && isset($body['_METHOD'])) {
$this->method = $this->filterMethod($body['_METHOD']);
$this->method = $this->filterMethod((string)$body['_METHOD']);
}

if ($this->getBody()->eof()) {
Expand Down Expand Up @@ -286,7 +286,7 @@ public function withMethod($method)
$method = $this->filterMethod($method);
$clone = clone $this;
$clone->originalMethod = $method;
$clone->method = null; // <-- Force method override recalculation
$clone->method = $method;

return $clone;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testWithMethod()
{
$request = $this->requestFactory()->withMethod('PUT');

$this->assertAttributeEquals(null, 'method', $request);
$this->assertAttributeEquals('PUT', 'method', $request);
$this->assertAttributeEquals('PUT', 'originalMethod', $request);
}

Expand Down

0 comments on commit 3b06f0f

Please sign in to comment.