Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 3db54a5

Browse files
committed
Adds validation to withParsedBody()
Per the PSR-7 spec, should only allow arrays, objects, or null values.
1 parent 4a957e0 commit 3db54a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ServerRequest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ public function getParsedBody()
180180
*/
181181
public function withParsedBody($data)
182182
{
183+
if (! is_array($data) && ! is_object($data) && null !== $data) {
184+
throw new InvalidArgumentException(sprintf(
185+
'%s expects a null, array, or object argument; received %s',
186+
__METHOD__,
187+
gettype($data)
188+
));
189+
}
190+
183191
$new = clone $this;
184192
$new->parsedBody = $data;
185193
return $new;

0 commit comments

Comments
 (0)