Skip to content

Commit 9395718

Browse files
Merge branch '3.0'
* 3.0: [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 [FrameworkBundle] Better output for user in ContainerDebugCommand [Routing] add query param if value is different from default
2 parents 456e9dd + d9deeca commit 9395718

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
@@ -374,10 +374,11 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath,
374374
}
375375

376376
if ($i + 1 < $propertyPath->getLength()) {
377-
$zval[self::VALUE][$property] = array();
378-
379377
if (isset($zval[self::REF])) {
378+
$zval[self::VALUE][$property] = array();
380379
$zval[self::REF] = $zval[self::VALUE];
380+
} else {
381+
$zval[self::VALUE] = array($property => array());
381382
}
382383
}
383384
}

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)