Skip to content

Commit

Permalink
Update tests and make the exception message more clear on PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Sep 19, 2020
1 parent 899ef81 commit 45a3bf2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ public function toArray(): array
}

if (\PHP_VERSION_ID < 70300 && \JSON_ERROR_NONE !== json_last_error()) {
throw new JsonException(json_last_error_msg(), json_last_error());
throw new JsonException('Could not decode request body: ' . json_last_error_msg(), json_last_error());
}

if (!\is_array($content)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ public function testToArrayNonJson()
{
$req = new Request([], [], [], [], [], [], 'foobar');
$this->expectException(JsonException::class);
$this->expectExceptionMessage('Could not decode request body.');
$this->expectExceptionMessageMatches('|Could not decode request body.+|');
$req->toArray();
}

Expand Down

0 comments on commit 45a3bf2

Please sign in to comment.