Skip to content

Commit fb768b7

Browse files
Merge branch '3.4'
* 3.4: [HttpFoundation] refactoring: calculate when need [Serializer] Fix extra attributes when no group specified [Intl] Make intl-data tests pass and save language aliases again [FrameworkBundle][Config] fix: do not add resource checkers for debug=false [DI] Fix "almost-circular" dependencies handling [Console] Fix CommandTester::setInputs() docblock Only enabling validation if it is present Fix displaying errors for bootstrap 4 [Serializer] readd default argument value Fix reference dump for deprecated nodes [PhpUnitBridge] Fixed fatal error in CoverageListener when something goes wrong in Test::setUpBeforeClass [HttpKernel] Let the storage manage the session starts [VarDumper] fix trailling comma when dumping an exception [Validator] Fix TraceableValidator is reset on data collector instantiation Remove useless docblocks [FrameworkBundle] Fix docblocks [PropertyInfo] Remove useless docblocks
2 parents 34dff61 + 6ab0fde commit fb768b7

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
@@ -163,7 +163,7 @@ public function supportsDecoding($format)
163163
/**
164164
* Sets the root node name.
165165
*
166-
* @param string $name root node name
166+
* @param string $name Root node name
167167
*/
168168
public function setRootNodeName($name)
169169
{
@@ -261,8 +261,6 @@ final protected function isElementNameValid($name)
261261
/**
262262
* Parse the input DOMNode into an array or a string.
263263
*
264-
* @param \DOMNode $node xml to parse
265-
*
266264
* @return array|string
267265
*/
268266
private function parseXml(\DOMNode $node, array $context = array())
@@ -297,8 +295,6 @@ private function parseXml(\DOMNode $node, array $context = array())
297295
/**
298296
* Parse the input DOMNode attributes into an array.
299297
*
300-
* @param \DOMNode $node xml to parse
301-
*
302298
* @return array
303299
*/
304300
private function parseXmlAttributes(\DOMNode $node, array $context = array())
@@ -332,8 +328,6 @@ private function parseXmlAttributes(\DOMNode $node, array $context = array())
332328
/**
333329
* Parse the input DOMNode value (content and children) into an array or a string.
334330
*
335-
* @param \DOMNode $node xml to parse
336-
*
337331
* @return array|string
338332
*/
339333
private function parseXmlValue(\DOMNode $node, array $context = array())
@@ -547,7 +541,7 @@ private function resolveXmlTypeCastAttributes(array $context = array())
547541
/**
548542
* Create a DOM document, taking serializer options into account.
549543
*
550-
* @param array $context options that the encoder has access to
544+
* @param array $context Options that the encoder has access to
551545
*
552546
* @return \DOMDocument
553547
*/

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
@@ -35,6 +35,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
3535
const OBJECT_TO_POPULATE = 'object_to_populate';
3636
const GROUPS = 'groups';
3737
const ATTRIBUTES = 'attributes';
38+
const ALLOW_EXTRA_ATTRIBUTES = 'allow_extra_attributes';
3839

3940
/**
4041
* @var int
@@ -83,7 +84,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
8384
/**
8485
* Set circular reference limit.
8586
*
86-
* @param int $circularReferenceLimit limit of iterations for the same object
87+
* @param int $circularReferenceLimit Limit of iterations for the same object
8788
*
8889
* @return self
8990
*/
@@ -111,7 +112,7 @@ public function setCircularReferenceHandler(callable $circularReferenceHandler)
111112
/**
112113
* Set normalization callbacks.
113114
*
114-
* @param callable[] $callbacks help normalize the result
115+
* @param callable[] $callbacks Help normalize the result
115116
*
116117
* @return self
117118
*
@@ -205,7 +206,14 @@ protected function handleCircularReference($object)
205206
*/
206207
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
207208
{
208-
if (!$this->classMetadataFactory || !isset($context[static::GROUPS]) || !is_array($context[static::GROUPS])) {
209+
if (!$this->classMetadataFactory) {
210+
return false;
211+
}
212+
213+
$groups = false;
214+
if (isset($context[static::GROUPS]) && is_array($context[static::GROUPS])) {
215+
$groups = $context[static::GROUPS];
216+
} elseif (!isset($context[static::ALLOW_EXTRA_ATTRIBUTES]) || $context[static::ALLOW_EXTRA_ATTRIBUTES]) {
209217
return false;
210218
}
211219

@@ -214,7 +222,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu
214222
$name = $attributeMetadata->getName();
215223

216224
if (
217-
count(array_intersect($attributeMetadata->getGroups(), $context[static::GROUPS])) &&
225+
(false === $groups || count(array_intersect($attributeMetadata->getGroups(), $groups))) &&
218226
$this->isAllowedAttribute($classOrObject, $name, null, $context)
219227
) {
220228
$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)