|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-20 14:10 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jun 15 03:00:02 2026 UTC |
Description: ------------ From the documentation it is unclear: What happens when I want to assign a property by reference using ReflectionProperty::setValue. Also unclear what happens with ReflectionProperty::getValue. Maybe this should also be a Feature Request, requesting additional methods that set a reference / return a reference. In my opinion it is not necessary to create a special getValueByRef method, only the setValueByRef is necessary (getValue could always return by ref because you still need the other & for it to work). Reproduce code: --------------- class MyClass { public $myProperty; } $obj = new MyClass; $globalProp = 'value1'; $refl = new ReflectionObject($obj); $reflProp = $refl->getProperty('myProperty'); $reflProp->setValue($obj, $globalProp); $globalProp = 'value2'; // what will the next line print: value1 or value2 => not clear from the documentation echo $obj->myProperty; // prints value1 //------ class MyClass { public $myProperty = 'value1'; } $obj = new MyClass; $refl = new ReflectionObject($obj); $reflProp = $refl->getProperty('myProperty'); $globalProp = & $reflProp->getValue($obj); $globalProp = 'value2'; // what will the next line print: value1 or value2 => unclear according to docs echo $obj->myProperty; // print value1 & E_STRICT is raised