ID: 38176
Updated by: [EMAIL PROTECTED]
Reported By: pedro dot leite dot rocha at gmail dot com
-Status: Assigned
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux 2.6.15-26-686
PHP Version: 5.1.4
Assigned To: dmitry
New Comment:
This is not a bug (may be a logical inconsistency).
Method __set() is used for modification values of overloaded properties
and it cannot be used to assigment by reference.
Implement method __get and you will get "Fatal error: Cannot assign by
reference to overloaded object ...".
Previous Comments:
------------------------------------------------------------------------
[2006-07-21 15:04:56] pedro dot leite dot rocha at gmail dot com
Description:
------------
When using overloading with the special function __set, and passing the
value by reference, the overload is ignored, and a new attribute for the
class object is created.
I'm not sure if this is a bug, but I couldn't find anything like it in
the documentation, or in the bug list. Appreciate the help.
[]'s
Reproduce code:
---------------
class A {
private $v;
function __construct() {
echo "constructing...\n";
}
function __set($key, $value) {
echo "setting ".$key."\n";
$this->v[$key] = $value;
}
}
$foo = "bar";
$a = new A;
echo "without reference:\n";
$a->user = $foo;
echo "with reference:\n";
$a->user =& $foo;
var_dump($a);
Expected result:
----------------
constructing...
without reference:
setting user
with reference:
object(A)#1 (2) {
["v:private"]=>
array(1) {
["user"]=>
&string(3) "bar"
}
}
Actual result:
--------------
constructing...
without reference:
setting user
with reference:
object(A)#1 (2) {
["v:private"]=>
array(1) {
["user"]=>
string(3) "bar"
}
["user"]=>
&string(3) "bar"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38176&edit=1