ID: 41387 User updated by: peter at ibuildings dot nl Reported By: peter at ibuildings dot nl Status: Bogus Bug Type: Documentation problem Operating System: Windows XP Professional PHP Version: 5.2.2 New Comment:
Check the bug number and date, this one is the oldest. Previous Comments: ------------------------------------------------------------------------ [2007-08-17 08:31:37] [EMAIL PROTECTED] Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Same as bug #41641. ------------------------------------------------------------------------ [2007-05-14 20:29:31] peter at ibuildings dot nl So it seems PHP has lost some of it's "magic". This means that if you want to add an element to an array stored in an instance variable of a certain object you always need to be sure it's a real declared instance variable and not a "magic" instance variable. Seems a big loss to me. Can it not be implemented in a future version that if you declare the method as "&__get" that it works like it did before PHP 5.2 and if you declare the method as "__get" you get the PHP 5.2 behavior? Then both ways are possible and because of the explicit declaration of returning a reference (or not) it's clear what the method does. If you implement the ArrayIterator interface, do you then stumble upon the same changed behavior? So if you implement this interface and then try to add an element to a "magic" array element (e.g. $this['a'][] = 1;), you also get a notice of some sort? ------------------------------------------------------------------------ [2007-05-14 19:10:24] [EMAIL PROTECTED] But it is not a bug. As I am not sure if this is mentioned in the docs, I marked it as a documentation problem. ------------------------------------------------------------------------ [2007-05-14 08:43:37] peter at ibuildings dot nl Ok, but this did work using PHP 5.1.6 so you can call this a regression. If I understand this correctly the only way to work-around this is using some code like the following: $b = array(); $b[] = '1'; $b[] = '2'; $b[] = '3'; $obj->b = $b; Or in a more realistic case where other methods assign something to the object: $b = $obj->b; $b[] = '3'; $obj->b = $b; Seems not very intuitive to me. ------------------------------------------------------------------------ [2007-05-14 08:27:42] judas dot iscariote at gmail dot com turn on error reporting and you will find the cause. PHP Notice: Indirect modification of overloaded property Data::$b has no effect. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/41387 -- Edit this bug report at http://bugs.php.net/?id=41387&edit=1