Skip to content

Commit

Permalink
Fix json-encoding when JSON_THROW_ON_ERROR is used
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 5, 2019
1 parent ac4ad2b commit 7c77e01
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ public function setData($data = [])
restore_error_handler();
}
} else {
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) {
// Work around https://bugs.php.net/77997
json_encode(null);
}

try {
$data = json_encode($data, $this->encodingOptions);
} catch (\Exception $e) {
Expand All @@ -166,6 +161,10 @@ public function setData($data = [])
}
throw $e;
}

if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) {
return $this->setJson($data);
}
}
}

Expand Down

0 comments on commit 7c77e01

Please sign in to comment.