#45772 [NEW]: ReflectionProperty::setValue/getValue how are "by reference" calls done?
From: jtaal at eljakim dot nl
Operating system: Irrelevant
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: ReflectionProperty::setValue/getValue how are "by reference" calls done?
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
--
Edit bug report at http://bugs.php.net/?id=45772&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45772&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45772&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45772&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45772&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45772&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45772&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45772&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45772&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45772&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45772&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45772&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45772&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45772&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45772&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45772&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45772&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45772&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45772&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45772&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45772&r=mysqlcfg
Thread (2 messages)
- jtaal at eljakim dot nl