Skip to content

Commit 6ab0fde

Browse files
Merge branch '3.3' into 3.4
* 3.3: [Serializer] Fix extra attributes when no group specified [Intl] Make intl-data tests pass and save language aliases again [Console] Fix CommandTester::setInputs() docblock [Serializer] readd default argument value [VarDumper] fix trailling comma when dumping an exception Remove useless docblocks [FrameworkBundle] Fix docblocks [PropertyInfo] Remove useless docblocks
2 parents 5b4b30d + ff3821f commit 6ab0fde

18 files changed

+80
-74
lines changed

Encoder/DecoderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface DecoderInterface
2525
*
2626
* @param string $data Data to decode
2727
* @param string $format Format name
28-
* @param array $context options that decoders have access to
28+
* @param array $context Options that decoders have access to
2929
*
3030
* The format parameter specifies which format the data is in; valid values
3131
* depend on the specific implementation. Authors implementing this interface
@@ -41,7 +41,7 @@ public function decode($data, $format, array $context = array());
4141
/**
4242
* Checks whether the deserializer can decode from given format.
4343
*
44-
* @param string $format format name
44+
* @param string $format Format name
4545
*
4646
* @return bool
4747
*/

Encoder/EncoderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface EncoderInterface
2525
*
2626
* @param mixed $data Data to encode
2727
* @param string $format Format name
28-
* @param array $context options that normalizers/encoders have access to
28+
* @param array $context Options that normalizers/encoders have access to
2929
*
3030
* @return scalar
3131
*
@@ -36,7 +36,7 @@ public function encode($data, $format, array $context = array());
3636
/**
3737
* Checks whether the serializer can encode to given format.
3838
*
39-
* @param string $format format name
39+
* @param string $format Format name
4040
*
4141
* @return bool
4242
*/

Encoder/JsonDecode.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,12 @@
2020
*/
2121
class JsonDecode implements DecoderInterface
2222
{
23-
/**
24-
* Specifies if the returned result should be an associative array or a nested stdClass object hierarchy.
25-
*
26-
* @var bool
27-
*/
28-
private $associative;
23+
protected $serializer;
2924

30-
/**
31-
* Specifies the recursion depth.
32-
*
33-
* @var int
34-
*/
25+
private $associative;
3526
private $recursionDepth;
36-
3727
private $lastError = JSON_ERROR_NONE;
3828

39-
protected $serializer;
40-
4129
/**
4230
* Constructs a new JsonDecode instance.
4331
*

Encoder/JsonEncoder.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@ class JsonEncoder implements EncoderInterface, DecoderInterface
2020
{
2121
const FORMAT = 'json';
2222

23-
/**
24-
* @var JsonEncode
25-
*/
2623
protected $encodingImpl;
27-
28-
/**
29-
* @var JsonDecode
30-
*/
3124
protected $decodingImpl;
3225

3326
public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodingImpl = null)

Encoder/XmlEncoder.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function supportsDecoding($format)
159159
/**
160160
* Sets the root node name.
161161
*
162-
* @param string $name root node name
162+
* @param string $name Root node name
163163
*/
164164
public function setRootNodeName($name)
165165
{
@@ -257,8 +257,6 @@ final protected function isElementNameValid($name)
257257
/**
258258
* Parse the input DOMNode into an array or a string.
259259
*
260-
* @param \DOMNode $node xml to parse
261-
*
262260
* @return array|string
263261
*/
264262
private function parseXml(\DOMNode $node, array $context = array())
@@ -293,8 +291,6 @@ private function parseXml(\DOMNode $node, array $context = array())
293291
/**
294292
* Parse the input DOMNode attributes into an array.
295293
*
296-
* @param \DOMNode $node xml to parse
297-
*
298294
* @return array
299295
*/
300296
private function parseXmlAttributes(\DOMNode $node, array $context = array())
@@ -328,8 +324,6 @@ private function parseXmlAttributes(\DOMNode $node, array $context = array())
328324
/**
329325
* Parse the input DOMNode value (content and children) into an array or a string.
330326
*
331-
* @param \DOMNode $node xml to parse
332-
*
333327
* @return array|string
334328
*/
335329
private function parseXmlValue(\DOMNode $node, array $context = array())
@@ -543,7 +537,7 @@ private function resolveXmlTypeCastAttributes(array $context = array())
543537
/**
544538
* Create a DOM document, taking serializer options into account.
545539
*
546-
* @param array $context options that the encoder has access to
540+
* @param array $context Options that the encoder has access to
547541
*
548542
* @return \DOMDocument
549543
*/

Mapping/Loader/FileLoader.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
*/
2121
abstract class FileLoader implements LoaderInterface
2222
{
23-
/**
24-
* @var string
25-
*/
2623
protected $file;
2724

2825
/**

Mapping/Loader/LoaderChain.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
*/
2828
class LoaderChain implements LoaderInterface
2929
{
30-
/**
31-
* @var LoaderInterface[]
32-
*/
3330
private $loaders;
3431

3532
/**

NameConverter/CamelCaseToSnakeCaseNameConverter.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
*/
1919
class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
2020
{
21-
/**
22-
* @var array|null
23-
*/
2421
private $attributes;
25-
26-
/**
27-
* @var bool
28-
*/
2922
private $lowerCamelCase;
3023

3124
/**

Normalizer/AbstractNormalizer.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
3333
const OBJECT_TO_POPULATE = 'object_to_populate';
3434
const GROUPS = 'groups';
3535
const ATTRIBUTES = 'attributes';
36+
const ALLOW_EXTRA_ATTRIBUTES = 'allow_extra_attributes';
3637

3738
/**
3839
* @var int
@@ -81,7 +82,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
8182
/**
8283
* Set circular reference limit.
8384
*
84-
* @param int $circularReferenceLimit limit of iterations for the same object
85+
* @param int $circularReferenceLimit Limit of iterations for the same object
8586
*
8687
* @return self
8788
*/
@@ -109,7 +110,7 @@ public function setCircularReferenceHandler(callable $circularReferenceHandler)
109110
/**
110111
* Set normalization callbacks.
111112
*
112-
* @param callable[] $callbacks help normalize the result
113+
* @param callable[] $callbacks Help normalize the result
113114
*
114115
* @return self
115116
*
@@ -203,7 +204,14 @@ protected function handleCircularReference($object)
203204
*/
204205
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
205206
{
206-
if (!$this->classMetadataFactory || !isset($context[static::GROUPS]) || !is_array($context[static::GROUPS])) {
207+
if (!$this->classMetadataFactory) {
208+
return false;
209+
}
210+
211+
$groups = false;
212+
if (isset($context[static::GROUPS]) && is_array($context[static::GROUPS])) {
213+
$groups = $context[static::GROUPS];
214+
} elseif (!isset($context[static::ALLOW_EXTRA_ATTRIBUTES]) || $context[static::ALLOW_EXTRA_ATTRIBUTES]) {
207215
return false;
208216
}
209217

@@ -212,7 +220,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu
212220
$name = $attributeMetadata->getName();
213221

214222
if (
215-
count(array_intersect($attributeMetadata->getGroups(), $context[static::GROUPS])) &&
223+
(false === $groups || count(array_intersect($attributeMetadata->getGroups(), $groups))) &&
216224
$this->isAllowedAttribute($classOrObject, $name, null, $context)
217225
) {
218226
$allowedAttributes[] = $attributesAsString ? $name : $attributeMetadata;

Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function normalize($object, $format = null, array $context = array())
110110
*
111111
* @return string[]
112112
*/
113-
protected function getAttributes($object, $format, array $context)
113+
protected function getAttributes($object, $format = null, array $context)
114114
{
115115
$class = get_class($object);
116116
$key = $class.'-'.$context['cache_key'];

0 commit comments

Comments
 (0)