Skip to content

Commit

Permalink
Merge pull request #1489 from akrabat/array-in-parsedbody
Browse files Browse the repository at this point in the history
Return arrays where possible for getParsedBody()
  • Loading branch information
silentworks committed Sep 7, 2015
2 parents c098a25 + 3fb0cd4 commit d4ac4db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Slim/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function __construct($method, UriInterface $uri, HeadersInterface $header
}

$this->registerMediaTypeParser('application/json', function ($input) {
return json_decode($input);
return json_decode($input, true);
});

$this->registerMediaTypeParser('application/xml', function ($input) {
Expand All @@ -191,7 +191,7 @@ public function __construct($method, UriInterface $uri, HeadersInterface $header

$this->registerMediaTypeParser('application/x-www-form-urlencoded', function ($input) {
parse_str($input, $data);
return (object)$data;
return $data;
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public function testGetParsedBodyForm()
$body = new RequestBody();
$body->write('foo=bar');
$request = new Request($method, $uri, $headers, $cookies, $serverParams, $body);
$this->assertEquals((object)['foo' => 'bar'], $request->getParsedBody());
$this->assertEquals(['foo' => 'bar'], $request->getParsedBody());
}

public function testGetParsedBodyJson()
Expand All @@ -709,7 +709,7 @@ public function testGetParsedBodyJson()
$body->write('{"foo":"bar"}');
$request = new Request($method, $uri, $headers, $cookies, $serverParams, $body);

$this->assertEquals((object)['foo' => 'bar'], $request->getParsedBody());
$this->assertEquals(['foo' => 'bar'], $request->getParsedBody());
}

public function testGetParsedBodyXml()
Expand Down

0 comments on commit d4ac4db

Please sign in to comment.