[HttpClient] work around PHP 7.3 bug related to json_encode()

This commit is contained in:
Nicolas Grekas 2019-06-04 20:58:48 +02:00
parent 40076b98bf
commit 42904e34e6
1 changed files with 7 additions and 1 deletions

View File

@ -301,7 +301,13 @@ trait HttpClientTrait
}
try {
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth);
if (\PHP_VERSION_ID >= 70300) {
// Work around https://bugs.php.net/77997
json_encode(null);
$flags |= JSON_THROW_ON_ERROR;
}
$value = json_encode($value, $flags, $maxDepth);
} catch (\JsonException $e) {
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
}