[Form] Fixed PropertyPath handling of __get() method that returns a constant
This commit is contained in:
parent
39e821c1eb
commit
6e1462e0c0
@ -213,6 +213,18 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame('foobar', $path->getValue($object));
|
$this->assertSame('foobar', $path->getValue($object));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://github.com/symfony/symfony/pull/4450
|
||||||
|
*/
|
||||||
|
public function testGetValueReadsMagicGetThatReturnsConstant()
|
||||||
|
{
|
||||||
|
$path = new PropertyPath('magicProperty');
|
||||||
|
|
||||||
|
$object = new Magician();
|
||||||
|
|
||||||
|
$this->assertNull($path->getValue($object));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Symfony\Component\Form\Exception\PropertyAccessDeniedException
|
* @expectedException Symfony\Component\Form\Exception\PropertyAccessDeniedException
|
||||||
*/
|
*/
|
||||||
|
@ -402,7 +402,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
|
|||||||
$result = $objectOrArray->$hasser();
|
$result = $objectOrArray->$hasser();
|
||||||
} elseif ($reflClass->hasMethod('__get')) {
|
} elseif ($reflClass->hasMethod('__get')) {
|
||||||
// needed to support magic method __get
|
// needed to support magic method __get
|
||||||
$result =& $objectOrArray->$property;
|
$result = $objectOrArray->$property;
|
||||||
} elseif ($reflClass->hasProperty($property)) {
|
} elseif ($reflClass->hasProperty($property)) {
|
||||||
if (!$reflClass->getProperty($property)->isPublic()) {
|
if (!$reflClass->getProperty($property)->isPublic()) {
|
||||||
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));
|
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));
|
||||||
|
Reference in New Issue
Block a user