Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc1cb357

Browse 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 parents40b4cb2 +fa68529 commitc1cb357

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines 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‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ public function testGetValueReadsArrayWithCustomPropertyPath()
9292

9393
publicfunctiontestGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
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
publicfunctiontestGetValueReadsProperty()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp