Skip to content

Commit

Permalink
[HttpFoundation] work around PHP 7.3 bug related to json_encode()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 4, 2019
1 parent 5de015a commit 6eec58d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Descriptor/JsonDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ protected function describeApplication(Application $application, array $options
*/
private function writeData(array $data, array $options)
{
$this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;

if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $flags)) {
// Work around https://bugs.php.net/77997
json_encode(null);
}

$this->write(json_encode($data, $flags));
}

/**
Expand Down

0 comments on commit 6eec58d

Please sign in to comment.