Skip to content

Commit 64506eb

Browse files
Merge branch '3.3' into 3.4
* 3.3: (21 commits) [appveyor] disable memory limit on composer up Remove some unused variables and properties Remove some unused variables, properties and methods fix some edge cases with indented blocks [ExpressionLanguage] Fix parse error on 5.3 [HttpKernel] remove noisy frame in controller stack traces [DI] Fix circular-aliases message [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice Prevent a loop in aliases within the `findDefinition` method Fix php doc in Table class bumped Symfony version to 3.3.15 updated VERSION for 3.3.14 updated CHANGELOG for 3.3.14 bumped Symfony version to 2.8.33 updated VERSION for 2.8.32 updated CHANGELOG for 2.8.32 bumped Symfony version to 2.7.40 updated VERSION for 2.7.39 update CONTRIBUTORS for 2.7.39 updated CHANGELOG for 2.7.39 ...
2 parents 18381bf + 8ea0465 commit 64506eb

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

Encoder/JsonDecode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class JsonDecode implements DecoderInterface
2424

2525
private $associative;
2626
private $recursionDepth;
27-
private $lastError = JSON_ERROR_NONE;
2827

2928
/**
3029
* Constructs a new JsonDecode instance.
@@ -75,7 +74,7 @@ public function decode($data, $format, array $context = array())
7574

7675
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
7776

78-
if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
77+
if (JSON_ERROR_NONE !== json_last_error()) {
7978
throw new NotEncodableValueException(json_last_error_msg());
8079
}
8180

Encoder/JsonEncode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
class JsonEncode implements EncoderInterface
2222
{
2323
private $options;
24-
private $lastError = JSON_ERROR_NONE;
2524

2625
public function __construct($bitmask = 0)
2726
{
@@ -39,7 +38,7 @@ public function encode($data, $format, array $context = array())
3938

4039
$encodedJson = json_encode($data, $context['json_encode_options']);
4140

42-
if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
41+
if (JSON_ERROR_NONE !== json_last_error()) {
4342
throw new NotEncodableValueException(json_last_error_msg());
4443
}
4544

Normalizer/AbstractNormalizer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ protected function createChildContext(array $parentContext, $attribute)
399399
{
400400
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
401401
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
402+
} else {
403+
unset($parentContext[self::ATTRIBUTES]);
402404
}
403405

404406
return $parentContext;

Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,16 @@ public function testAttributesContextNormalize()
683683
),
684684
$serializer->normalize($objectDummy, null, $context)
685685
);
686+
687+
$context = array('attributes' => array('foo', 'baz', 'object'));
688+
$this->assertEquals(
689+
array(
690+
'foo' => 'foo',
691+
'baz' => true,
692+
'object' => array('foo' => 'innerFoo', 'bar' => 'innerBar'),
693+
),
694+
$serializer->normalize($objectDummy, null, $context)
695+
);
686696
}
687697

688698
public function testAttributesContextDenormalize()

0 commit comments

Comments
 (0)