Skip to content
Browse files

merged branch felicitus/master (PR #7494)

This PR was squashed before being merged into the master branch (closes #7494).

Discussion
----------

[master] Better documentation for

Fixes #7492

Commits
-------

b1e14b2 [master] Better documentation for
  • Loading branch information...
2 parents 2ff26b2 + b1e14b2 commit 8e8e3772dcf38597e076f71d38427be4138f86d9 @fabpot fabpot committed
View
12 src/Symfony/Component/Serializer/Encoder/DecoderInterface.php
@@ -21,16 +21,20 @@
/**
* Decodes a string into PHP data
*
- * @param scalar $data Data to decode
- * @param string $format Format name
- * @param array $context options that decoders have access to.
+ * @param scalar $data Data to decode
+ * @param string $format Format name
+ * @param array $context options that decoders have access to.
+ *
+ * The format parameter specifies which format the data is in; valid values depend on the specific implementation.
+ * Authors implementing this interface are encouraged to document which formats they support in a non-inherited
+ * phpdoc comment.
*
* @return mixed
*/
public function decode($data, $format, array $context = array());
/**
- * Checks whether the serializer can decode from given format
+ * Checks whether the deserializer can decode from given format
*
* @param string $format format name
*
View
39 src/Symfony/Component/Serializer/Encoder/JsonDecode.php
@@ -18,15 +18,31 @@
*/
class JsonDecode implements DecoderInterface
{
+ /**
+ * Specifies if the returned result should be an associative array or a nested stdClass object hierarchy
+ * @var bool
+ */
private $associative;
+
+ /**
+ * Specifies the recursion depth
+ * @var int
+ */
private $recursionDepth;
+
private $lastError = JSON_ERROR_NONE;
protected $serializer;
+ /**
+ * Constructs a new JsonDecode instance.
+ *
+ * @param bool $associative True to return the result associative array, false for a nested stdClass hierarchy.
+ * @param int $depth Specifies the recursion depth
+ */
public function __construct($associative = false, $depth = 512)
{
$this->associative = $associative;
- $this->recursionDepth = $depth;
+ $this->recursionDepth = (int)$depth;
}
/**
@@ -42,12 +58,27 @@ public function getLastError()
}
/**
- * Decodes a JSON string into PHP data
+ * @param string $data The encoded JSON string to decode
+ * @param string $format Must be set to JsonEncoder::FORMAT
+ * @param array $context An optional set of options for the JSON decoder; see below.
+ *
+ * The $context array is a simple key=>value array, with the following supported keys:
*
- * @param string $data JSON
- * @param string $format
+ * json_decode_associative: boolean
+ * If true, returns the object as associative array.
+ * If false, returns the object as nested StdClass
+ * If not specified, this method will use the default set in JsonDecode::__construct
+ *
+ * json_decode_recursion_depth: integer
+ * Specifies the maximum recursion depth
+ * If not specified, this method will use the default set in JsonDecode::__construct
+ *
+ * json_decode_options: integer
+ * Specifies additional options as per documentation for json_decode. Only supported with PHP 5.4.0 and higher.
*
* @return mixed
+ *
+ * @see http://php.net/json_decode json_decode
*/
public function decode($data, $format, array $context = array())
{

0 comments on commit 8e8e377

Please sign in to comment.
Something went wrong with that request. Please try again.