#26441 [Bgs->Opn]: Strange behavior when __set() return a member variable
| From: | amt@php.net | Date: | Wed, 31 Mar 2004 23:46:46 +0000 |
| Subject: | #26441 [Bgs->Opn]: Strange behavior when __set() return a member variable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-57282@lists.php.net to get a copy of this message | ||
ID: 26441
Updated by: amt@php.net
Reported By: chernyshevsky at hotmail dot com
-Status: Bogus
+Status: Open
Bug Type: Zend Engine 2 problem
-Operating System: Win32
+Operating System: *
-PHP Version: 5.0.0b2 (beta2)
+PHP Version: 5CVS-2004-03-30
New Comment:
This looks to me like a legitimate bug. Why was this
bogused?
You can return other values from __set() without
triggering this error and it makes sense to return
$this->values[$name] to make it consistent with non-
overloaded property writes.
Previous Comments:
------------------------------------------------------------------------
[2003-11-28 20:33:54] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
..
------------------------------------------------------------------------
[2003-11-28 01:13:50] chernyshevsky at hotmail dot com
Description:
------------
When __set() returns an element of a member array, it seems to corrupt
the array. Works as expected when "return" is removed.
Reproduce code:
---------------
class Test {
var $values;
function __construct() {
$this->values = array();
}
function __set($name, $value) {
return $this->values[$name] = $value;
}
function __get($name) {
return $this->values[$name];
}
};
$a = new Test();
$a->greeting = "Hello";
echo $a->greeting;
Expected result:
----------------
Hello
Actual result:
--------------
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26441&edit=1