ID: 26441 User updated by: chernyshevsky at hotmail dot com Reported By: chernyshevsky at hotmail dot com Status: Open Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2004-03-30 New Comment:
I think it was marked bogus because you don't actually need to return from __set(). The engine will call __get() when you have something like $a = $object->prop = "Hello". Previous Comments: ------------------------------------------------------------------------ [2004-03-31 18:46:45] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [2003-11-28 20:33:54] [EMAIL PROTECTED] 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