Skip to content

Commit dcfc5c5

Browse files
Merge branch '3.4' into 4.0
* 3.4: (37 commits) Remove some unused variables and properties [appveyor] disable memory limit on composer up [HttpFoundation] don't prefix cookies with "Set-Cookie:" Remove some unused variables and properties Fix debug:form definition 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] Force root-namespace for function calls in the dumper container [DI] Fix circular-aliases message register system cache clearer only if it's used doc : Namespace prefix must end with a "\" [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice Prevent a loop in aliases within the `findDefinition` method [HttpKernel] Disable inlining on PHP 5 Ensure that inlined services with parameterized class name can be dumped [DI] Fix non-string class handling in PhpDumper Throw a sensible exception when controller has been removed Remove LOCK_EX That Breaks Cache Usage on NFS ...
2 parents 7343d18 + 64506eb commit dcfc5c5

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

Encoder/CsvEncoder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function decode($data, $format, array $context = array())
109109

110110
$headers = null;
111111
$nbHeaders = 0;
112+
$headerCount = array();
112113
$result = array();
113114

114115
list($delimiter, $enclosure, $escapeChar, $keySeparator) = $this->getCsvOptions($context);
@@ -120,15 +121,17 @@ public function decode($data, $format, array $context = array())
120121
$nbHeaders = $nbCols;
121122

122123
foreach ($cols as $col) {
123-
$headers[] = explode($keySeparator, $col);
124+
$header = explode($keySeparator, $col);
125+
$headers[] = $header;
126+
$headerCount[] = count($header);
124127
}
125128

126129
continue;
127130
}
128131

129132
$item = array();
130133
for ($i = 0; ($i < $nbCols) && ($i < $nbHeaders); ++$i) {
131-
$depth = count($headers[$i]);
134+
$depth = $headerCount[$i];
132135
$arr = &$item;
133136
for ($j = 0; $j < $depth; ++$j) {
134137
// Handle nested arrays

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(int $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
@@ -388,6 +388,8 @@ protected function createChildContext(array $parentContext, $attribute)
388388
{
389389
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
390390
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
391+
} else {
392+
unset($parentContext[self::ATTRIBUTES]);
391393
}
392394

393395
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)