ID: 47215 Updated by: [email protected] Reported By: remy dot damour at laposte dot net -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: debian PHP Version: 5.2.8 New Comment:
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 . Previous Comments: ------------------------------------------------------------------------ [2009-01-25 22:55:35] remy dot damour at laposte dot net Maybe this is not a bug, but simply expected behavior? Because otherwise we could not be able to define object properties using __set() magic method Regards, Remy ------------------------------------------------------------------------ [2009-01-25 22:23:41] remy dot damour at laposte dot net Description: ------------ Magic method __set() is bypassed on recursive call. PHP automatically creates a property on instance instead of recursively calling __set() or instead of throwing a recursivity error For additional details, please read: http://www.qc4blog.com/?p=458 Reproduce code: --------------- class Fruits { protected $_props = array(); // inner array mapping properties to values public function __set($name, $value) { $this->_props[$name] = $value; if ('apple' == $name) { $this->apple = 'green'; } } } $a = new Fruits(); $a->banana = 'yellow'; var_dump(property_exists($a, 'banana')); // output: false $a->apple = 'red'; var_dump(property_exists($a, 'apple')); // output: true Expected result: ---------------- Throw a recursivity exception Actual result: -------------- no exception thrown, property is automatically created by passing __set() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47215&edit=1
