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

Commit0885ebb

Browse files
committed
Merge branch '5.1'
* 5.1: Revert "bug#37622 [PropertyAccess] Fix accessing dynamic properties (andreyserdjuk)"
2 parents45329ab +47b9b5c commit0885ebb

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
@@ -450,16 +450,10 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid
450450

451451
throw$e;
452452
}
453-
}elseif (property_exists($object,$property)) {
454-
try {
455-
$result[self::VALUE] =$object->$property;
456-
if (isset($zval[self::REF])) {
457-
$result[self::REF] = &$object->$property;
458-
}
459-
}catch (\Error$e) {
460-
if (!$ignoreInvalidProperty) {
461-
thrownewNoSuchPropertyException(sprintf('Can\'t read protected or private property "%s" in class "%s".',$property,$class),0,$e);
462-
}
453+
}elseif ($objectinstanceof \stdClass &&property_exists($object,$property)) {
454+
$result[self::VALUE] =$object->$property;
455+
if (isset($zval[self::REF])) {
456+
$result[self::REF] = &$object->$property;
463457
}
464458
}elseif (!$ignoreInvalidProperty) {
465459
thrownewNoSuchPropertyException(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
@@ -22,7 +22,6 @@
2222
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidArgumentLength;
2323
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidMethods;
2424
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestClass;
25-
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestClassDynamicProperty;
2625
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestClassIsWritable;
2726
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall;
2827
useSymfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicGet;
@@ -99,29 +98,6 @@ public function testGetValue($objectOrArray, $path, $value)
9998
$this->assertSame($value,$this->propertyAccessor->getValue($objectOrArray,$path));
10099
}
101100

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp