Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / serializer / Encoder / JsonDecode.php
index 9acb2bc5a8300a8f7e6577563b78789378b65891..bee1f7d4449f4f2d0390d66607258268b32ac33e 100644 (file)
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\Serializer\Encoder;
 
-use Symfony\Component\Serializer\Exception\UnexpectedValueException;
+use Symfony\Component\Serializer\Exception\NotEncodableValueException;
 
 /**
  * Decodes JSON data.
@@ -20,24 +20,11 @@ use Symfony\Component\Serializer\Exception\UnexpectedValueException;
  */
 class JsonDecode implements DecoderInterface
 {
-    /**
-     * Specifies if the returned result should be an associative array or a nested stdClass object hierarchy.
-     *
-     * @var bool
-     */
-    private $associative;
+    protected $serializer;
 
-    /**
-     * Specifies the recursion depth.
-     *
-     * @var int
-     */
+    private $associative;
     private $recursionDepth;
 
-    private $lastError = JSON_ERROR_NONE;
-
-    protected $serializer;
-
     /**
      * Constructs a new JsonDecode instance.
      *
@@ -50,22 +37,6 @@ class JsonDecode implements DecoderInterface
         $this->recursionDepth = (int) $depth;
     }
 
-    /**
-     * Returns the last decoding error (if any).
-     *
-     * @return int
-     *
-     * @deprecated since version 2.5, to be removed in 3.0.
-     *             The {@self decode()} method 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 decode() method instead to get the last JSON decoding error.', E_USER_DEPRECATED);
-
-        return $this->lastError;
-    }
-
     /**
      * Decodes data.
      *
@@ -89,7 +60,7 @@ class JsonDecode implements DecoderInterface
      *
      * @return mixed
      *
-     * @throws UnexpectedValueException
+     * @throws NotEncodableValueException
      *
      * @see http://php.net/json_decode json_decode
      */
@@ -101,14 +72,10 @@ class JsonDecode implements DecoderInterface
         $recursionDepth = $context['json_decode_recursion_depth'];
         $options = $context['json_decode_options'];
 
-        if (\PHP_VERSION_ID >= 50400) {
-            $decodedData = json_decode($data, $associative, $recursionDepth, $options);
-        } else {
-            $decodedData = json_decode($data, $associative, $recursionDepth);
-        }
+        $decodedData = json_decode($data, $associative, $recursionDepth, $options);
 
-        if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
-            throw new UnexpectedValueException(json_last_error_msg());
+        if (JSON_ERROR_NONE !== json_last_error()) {
+            throw new NotEncodableValueException(json_last_error_msg());
         }
 
         return $decodedData;
@@ -125,8 +92,6 @@ class JsonDecode implements DecoderInterface
     /**
      * Merges the default options of the Json Decoder with the passed context.
      *
-     * @param array $context
-     *
      * @return array
      */
     private function resolveContext(array $context)