Skip to content

Commit 262f739

Browse files
Merge branch '2.3' into 2.7
* 2.3: [PropertyAccess] ->getValue() should be read-only [Config] Fix XmlUtilsTest namespace [Routing] add query param if value is different from default Conflicts: src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
2 parents 06894a2 + 7a828ba commit 262f739

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)