Skip to content

Commit 1d6f018

Browse files
Merge branch '2.7' into 2.8
* 2.7: [PropertyAccess] ->getValue() should be read-only [VarDumper] Fix dumping type hints for non-existing parent classes [Config] Fix XmlUtilsTest namespace [Console] [TableHelper] make it work with SymfonyStyle. Remove dead code [Routing] add query param if value is different from default Conflicts: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
2 parents 3992ef9 + 262f739 commit 1d6f018

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

PropertyAccessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,11 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath,
373373
}
374374

375375
if ($i + 1 < $propertyPath->getLength()) {
376-
$zval[self::VALUE][$property] = array();
377-
378376
if (isset($zval[self::REF])) {
377+
$zval[self::VALUE][$property] = array();
379378
$zval[self::REF] = $zval[self::VALUE];
379+
} else {
380+
$zval[self::VALUE] = array($property => array());
380381
}
381382
}
382383
}

Tests/PropertyAccessorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ public function testGetValueReadsMagicGet()
126126
$this->assertSame('Bernhard', $this->propertyAccessor->getValue(new TestClassMagicGet('Bernhard'), 'magicProperty'));
127127
}
128128

129+
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
130+
{
131+
$object = new \ArrayObject();
132+
$array = array('child' => array('index' => $object));
133+
134+
$this->assertNull($this->propertyAccessor->getValue($array, '[child][index][foo][bar]'));
135+
$this->assertSame(array(), $object->getArrayCopy());
136+
}
137+
129138
// https://github.com/symfony/symfony/pull/4450
130139
public function testGetValueReadsMagicGetThatReturnsConstant()
131140
{

0 commit comments

Comments
 (0)