ID: 39337 Updated by: [EMAIL PROTECTED] Reported By: phpbugs at thequod dot de -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Ubuntu Linux PHP Version: 5CVS-2006-11-01 (CVS) New Comment:
foo property is not actually created, hence the warning. Previous Comments: ------------------------------------------------------------------------ [2007-01-07 19:31:07] phpbugs at thequod dot de iliaa, thanks for taking the time to look at this. Unfortunately I don't understand your note. A::$foo is overloaded in class B and there it shows the IMHO correct behaviour (because in class B there's "var $foo"). The expected result in the last code example would have been: A: ---------------- array(1) { [0]=> int(1) } B: ---------------- array(1) { [0]=> int(1) } instead of: A: ---------------- array(0) { } B: ---------------- array(1) { [0]=> int(1) } ------------------------------------------------------------------------ [2007-01-07 04:10:47] [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 Notice: Indirect modification of overloaded property A::$foo has no effect. This is why the assignment has no effect. ------------------------------------------------------------------------ [2006-11-09 19:01:54] phpbugs at thequod dot de Re: I've also said it before.. it works, if the var is set in the constructor. To see the diff: ------------------------------------ <?php class A { private $vars; function __get($v) { if( isset($this->vars[$v]) ) return $this->vars[$v]; return array(); } function __set($v, $vv) { echo "__set: '$v'\n"; var_dump($vv); $this->vars[$v] = $vv; } } class B extends A { var $foo; } $A = new A(); $B = new B(); echo "A: ----------------\n"; $A->foo[] = 1; var_dump( $A->foo ); echo "B: ----------------\n"; $B->foo[] = 1; var_dump( $B->foo ); ?> ----------------------------------- Result: ------- A: ---------------- array(0) { } B: ---------------- array(1) { [0]=> int(1) } ------------------------------------------------------------------------ [2006-11-09 18:41:22] phpbugs at thequod dot de Ok. I've even slept over it. Why should this not work? --------------------------------- <?php class A { function __get($v) { if( isset($this->var) ) return $this->var; return array(); } } $A = new A(); $A->foo[] = 1; var_dump( $A->foo ); ?> --------------------------------- It prints: array(0) { } Your comment, which I've reread carefully, does not explain it. The temp var from __get() is first array and later the $var itself. Adding a __set() method to the class shows that this does not get called at all. ------------------------------------------------------------------------ [2006-11-09 00:30:50] [EMAIL PROTECTED] I've already explained everything, just read my previous comment carefully. ------------------------------------------------------------------------ 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/39337 -- Edit this bug report at http://bugs.php.net/?id=39337&edit=1