8000 [Form] Fixed PropertyPath handling of __get() method that returns a c… · symfony/symfony@6e1462e · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 6e1462e

Browse files
committed
[Form] Fixed PropertyPath handling of __get() method that returns a constant
1 parent 39e821c commit 6e1462e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ public function testGetValueReadsMagicGet()
213213
$this->assertSame('foobar', $path->getValue($object));
214214
}
215215

216+
/*
217+
* https://github.com/symfony/symfony/pull/4450
218+
*/
219+
public function testGetValueReadsMagicGetThatReturnsConstant()
220+
{
221+
$path = new PropertyPath('magicProperty');
222+
223+
$object = new Magician();
224+
225+
$this->assertNull($path->getValue($object));
226+
}
227+
216228
/**
217229
* @expectedException Symfony\Component\Form\Exception\PropertyAccessDeniedException
218230
*/

src/Symfony/Component/Form/Util/PropertyPath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ protected function &readProperty(&$objectOrArray, $property, $isIndex)
402402
$result = $objectOrArray->$hasser();
403403
} elseif ($reflClass->hasMethod('__get')) {
404404
// needed to support magic method __get
405-
$result =& $objectOrArray->$property;
405+
$result = $objectOrArray->$property;
406406
} elseif ($reflClass->hasProperty($property)) {
407407
if (!$reflClass->getProperty($property)->isPublic()) {
408408
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $property, $reflClass->name, $getter, $isser));

0 commit comments

Comments
 (0)
0