#45772 [Opn->Bgs]: ReflectionProperty::setValue/getValue how are "by reference" calls done?

From: Date: Fri, 20 Nov 2009 14:10:24 +0000
Subject: #45772 [Opn->Bgs]: ReflectionProperty::setValue/getValue how are "by reference" calls done?
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3293@lists.php.net to get a copy of this message
 ID:               45772
 Updated by:       vrana@php.net
 Reported By:      jtaal at eljakim dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Documentation problem
 Operating System: Irrelevant
 PHP Version:      Irrelevant
 New Comment:

getValue and setValue clearly states that it takes the value, not the
reference.


Previous Comments:
------------------------------------------------------------------------

[2008-08-09 23:11:01] jtaal at eljakim dot nl

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 this bug report at http://bugs.php.net/?id=45772&edit=1



Thread (2 messages)

« previous php.doc.bugs (#3293) next »