ID: 39449 Updated by: [EMAIL PROTECTED] Reported By: pstradomski at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.2.0 New Comment:
This is expected behaviour. Previous Comments: ------------------------------------------------------------------------ [2006-11-09 13:43:27] pstradomski at gmail dot com Description: ------------ It is now impossible to implement overloaded array properties. Array returned via __get is now a copy (not a reference as in 5.1.x) and it is impossible to force getter to pass a reference. Reproduce code: --------------- <?php class A { public function & __get($val) { return $this->keys[$val]; } public function __set($k, $v) { $this->keys[$k] = $v; } private $keys = array(); } $a =new A(); $a->arr = array('a','b','c'); $b = &$a->arr; $b[]= 'd'; foreach ($a->arr as $k => $v) { echo "$k => $v\n"; } $a->arr[]='d'; foreach ($a->arr as $k => $v) { echo "$k => $v\n"; } ?> Expected result: ---------------- 0 => a 1 => b 2 => c 3 => d 0 => a 1 => b 2 => c 3 => d 4 => d Actual result: -------------- Notice: Indirect modification of overloaded property A::$arr has no effect in /home/pawel/tmp/a.php on line 18 Notice: Indirect modification of overloaded property A::$arr has no effect in /home/pawel/tmp/a.php on line 21 0 => a 1 => b 2 => c Notice: Indirect modification of overloaded property A::$arr has no effect in /home/pawel/tmp/a.php on line 25 Notice: Indirect modification of overloaded property A::$arr has no effect in /home/pawel/tmp/a.php on line 27 0 => a 1 => b 2 => c ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39449&edit=1