10000 Revert "bug #37622 [PropertyAccess] Fix accessing dynamic properties … · symfony/symfony@47b9b5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 47b9b5c

Browse files
committed
Revert "bug #37622 [PropertyAccess] Fix accessing dynamic properties (andreyserdjuk)"
This reverts commit 92cb709, reversing changes made to fc3095f.
1 parent c367e26 commit 47b9b5c

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,10 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid
435435

436436
throw $e;
437437
}
438-
} elseif (property_exists($object, $property)) {
439-
try {
440-
$result[self::VALUE] = $object->$property;
441-
if (isset($zval[self::REF])) {
442-
$result[self::REF] = &$object->$property;
443-
}
444-
} catch (\Error $e) {
445-
if (!$ignoreInvalidProperty) {
446-
throw new NoSuchPropertyException(sprintf('Can\'t read protected or private property "%s" in class "%s".', $property, $class), 0, $e);
447-
}
438+
} elseif ($object instanceof \stdClass && property_exists($object, $property)) {
439+
$result[self::VALUE] = $object->$property;
440+
if (isset($zval[self::REF])) {
441+
$result[self::REF] = &$object->$property;
448442
}
449443
} elseif (!$ignoreInvalidProperty) {
450444
throw new NoSuchPropertyException(sprintf('Can\'t get a way to read the property "%s" in class "%s".', $property, $class));

src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassDynamicProperty.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidArgumentLength;
2222
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidMethods;
2323
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass;
24-
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassDynamicProperty;
2524
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassIsWritable;
2625
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall;
2726
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicGet;
@@ -98,29 +97,6 @@ public function testGetValue($objectOrArray, $path, $value)
9897
$this->assertSame($value, $this->propertyAccessor->getValue($objectOrArray, $path));
9998
}
10099

101-
/**
102-
* Test get dynamic value from object is other than \stdClass instance.
103-
*/
104-
public function testGetDynamicValue()
105-
{
106-
$value = 'dynamicPropertyValue';
107-
$path = 'dynamicProperty';
108-
$object = new TestClassDynamicProperty($value);
109-
110-
$this->assertSame($value, $this->propertyAccessor->getValue($object, $path));
111-
}
112-
113-
/**
114-
* Ensure exact exception with message was thrown on access to non-public property.
115-
*/
116-
public function testGetInaccessibleProperty()
117-
{
118-
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
119-
$this->expectExceptionMessage(sprintf('Can\'t read protected or private property "%s" in class "%s".', 'protectedProperty', TestClass::class));
120-
121-
$this->propertyAccessor->getValue(new TestClass('Bernhard'), 'protectedProperty');
122-
}
123-
124100
/**
125101
* @dataProvider getPathsWithMissingProperty
126102
*/

0 commit comments

Comments
 (0)
0