X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fserializer%2FEncoder%2FJsonEncode.php;h=ef084eeab2b9c2dc13ad6606be533b7dbf9a5588;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=454c0d6a114708a6e77cd91adaaa1cd09d009ccf;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/serializer/Encoder/JsonEncode.php b/vendor/symfony/serializer/Encoder/JsonEncode.php index 454c0d6a1..ef084eeab 100644 --- a/vendor/symfony/serializer/Encoder/JsonEncode.php +++ b/vendor/symfony/serializer/Encoder/JsonEncode.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Serializer\Encoder; -use Symfony\Component\Serializer\Exception\UnexpectedValueException; +use Symfony\Component\Serializer\Exception\NotEncodableValueException; /** * Encodes JSON data. @@ -21,29 +21,12 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException; class JsonEncode implements EncoderInterface { private $options; - private $lastError = JSON_ERROR_NONE; public function __construct($bitmask = 0) { $this->options = $bitmask; } - /** - * Returns the last encoding error (if any). - * - * @return int - * - * @deprecated since version 2.5, to be removed in 3.0. - * The {@self encode()} throws an exception if error found. - * @see http://php.net/manual/en/function.json-last-error.php json_last_error - */ - public function getLastError() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Catch the exception raised by the encode() method instead to get the last JSON encoding error.', E_USER_DEPRECATED); - - return $this->lastError; - } - /** * Encodes PHP data to a JSON string. * @@ -55,8 +38,8 @@ class JsonEncode implements EncoderInterface $encodedJson = json_encode($data, $context['json_encode_options']); - if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) { - throw new UnexpectedValueException(json_last_error_msg()); + if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($context['json_encode_options'] & JSON_PARTIAL_OUTPUT_ON_ERROR))) { + throw new NotEncodableValueException(json_last_error_msg()); } return $encodedJson; @@ -73,8 +56,6 @@ class JsonEncode implements EncoderInterface /** * Merge default json encode options with context. * - * @param array $context - * * @return array */ private function resolveContext(array $context = array())