Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c1cb357

Browse filesBrowse files
bug #18603 [PropertyAccess] ->getValue() should be read-only (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [PropertyAccess] ->getValue() should be read-only | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18601 | License | MIT | Doc PR | - Commits ------- fa68529 [PropertyAccess] ->getValue() should be read-only
2 parents 40b4cb2 + fa68529 commit c1cb357
Copy full SHA for c1cb357

File tree

Expand file treeCollapse file tree

2 files changed

+7
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-4
lines changed

‎src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyAccessor.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,11 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath,
275275
(is_array($zval[self::VALUE]) && !isset($zval[self::VALUE][$property]) && !array_key_exists($property, $zval[self::VALUE]))
276276
) {
277277
if ($i + 1 < $propertyPath->getLength()) {
278-
$zval[self::VALUE][$property] = array();
279-
280278
if (isset($zval[self::REF])) {
279+
$zval[self::VALUE][$property] = array();
281280
$zval[self::REF] = $zval[self::VALUE];
281+
} else {
282+
$zval[self::VALUE] = array($property => array());
282283
}
283284
}
284285
}

‎src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ public function testGetValueReadsArrayWithCustomPropertyPath()
9292

9393
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
9494
{
95-
$array = array('child' => array('index' => array()));
95+
$object = new \ArrayObject();
96+
$array = array('child' => array('index' => $object));
9697

97-
$this->assertNull($this->propertyAccessor->getValue($array, '[child][index][firstName]'));
98+
$this->assertNull($this->propertyAccessor->getValue($array, '[child][index][foo][bar]'));
99+
$this->assertSame(array(), $object->getArrayCopy());
98100
}
99101

100102
public function testGetValueReadsProperty()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.