Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PropertyAccess] Fix setting public property on a class having a magi…
…c getter | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A When using PropertyAccessor with an object having both a public property and a magic getter, and one wants to update this property, PropertyAccessor may lose the property reference. This occurs when the public property value is a hash: ```php class Foo { /** * Example: $this->someProperty['foo']['bar'] = 'baz' * @var array */ public $someProperty; public function __get($name) { // ... } } $obj = new Foo(); $obj->someProperty = ['foo' => ['bar' => 'some_value']]; $propertyAccessor->setValue($obj, 'someProperty[foo][bar]', 'another_value'); echo $obj->someProperty['foo']['bar']; // Before this patch: 'some_value' => fail // After this patch: 'another_value' => correct ``` Furthermore, public properties are always used before `__get()` by PHP. This bug is visible since v2.6.5 as d733a88 changed the way `setValue()` works.
- Loading branch information