Skip to content

Commit ce255ed

Browse files
committed
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
2 parents 3eb823d + 8635634 commit ce255ed

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

Encoder/DecoderInterface.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ interface DecoderInterface
2121
/**
2222
* Decodes a string into PHP data
2323
*
24-
* @param scalar $data Data to decode
25-
* @param string $format Format name
26-
* @param array $context options that decoders have access to.
24+
* @param scalar $data Data to decode
25+
* @param string $format Format name
26+
* @param array $context options that decoders have access to.
27+
*
28+
* The format parameter specifies which format the data is in; valid values depend on the specific implementation.
29+
* Authors implementing this interface are encouraged to document which formats they support in a non-inherited
30+
* phpdoc comment.
2731
*
2832
* @return mixed
2933
*/
3034
public function decode($data, $format, array $context = array());
3135

3236
/**
33-
* Checks whether the serializer can decode from given format
37+
* Checks whether the deserializer can decode from given format
3438
*
3539
* @param string $format format name
3640
*

Encoder/JsonDecode.php

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,31 @@
1818
*/
1919
class JsonDecode implements DecoderInterface
2020
{
21+
/**
22+
* Specifies if the returned result should be an associative array or a nested stdClass object hierarchy
23+
* @var bool
24+
*/
2125
private $associative;
26+
27+
/**
28+
* Specifies the recursion depth
29+
* @var int
30+
*/
2231
private $recursionDepth;
32+
2333
private $lastError = JSON_ERROR_NONE;
2434
protected $serializer;
2535

36+
/**
37+
* Constructs a new JsonDecode instance.
38+
*
39+
* @param bool $associative True to return the result associative array, false for a nested stdClass hierarchy.
40+
* @param int $depth Specifies the recursion depth
41+
*/
2642
public function __construct($associative = false, $depth = 512)
2743
{
2844
$this->associative = $associative;
29-
$this->recursionDepth = $depth;
45+
$this->recursionDepth = (int)$depth;
3046
}
3147

3248
/**
@@ -42,12 +58,27 @@ public function getLastError()
4258
}
4359

4460
/**
45-
* Decodes a JSON string into PHP data
61+
* @param string $data The encoded JSON string to decode
62+
* @param string $format Must be set to JsonEncoder::FORMAT
63+
* @param array $context An optional set of options for the JSON decoder; see below.
64+
*
65+
* The $context array is a simple key=>value array, with the following supported keys:
4666
*
47-
* @param string $data JSON
48-
* @param string $format
67+
* json_decode_associative: boolean
68+
* If true, returns the object as associative array.
69+
* If false, returns the object as nested StdClass
70+
* If not specified, this method will use the default set in JsonDecode::__construct
71+
*
72+
* json_decode_recursion_depth: integer
73+
* Specifies the maximum recursion depth
74+
* If not specified, this method will use the default set in JsonDecode::__construct
75+
*
76+
* json_decode_options: integer
77+
* Specifies additional options as per documentation for json_decode. Only supported with PHP 5.4.0 and higher.
4978
*
5079
* @return mixed
80+
*
81+
* @see http://php.net/json_decode json_decode
5182
*/
5283
public function decode($data, $format, array $context = array())
5384
{

0 commit comments

Comments
 (0)