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:

Ilia is talking about this warning:
Notice: Indirect modification of overloaded property A::$foo has no
effect


Previous Comments:
------------------------------------------------------------------------

[2007-01-14 05:26:37] phpbugs at thequod dot de

ilia, which warning are you talking about? There's no 
(PHP) warning?!

All I want to say is: overloading of arrays by 
e.g. "$Foo->bar[] = 1" does not work, if $bar is not 
defined as a member in the class definition (without a 
value, of course).

------------------------------------------------------------------------

[2007-01-07 21:57:20] [EMAIL PROTECTED]

foo property is not actually created, hence the warning.

------------------------------------------------------------------------

[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)
}

------------------------------------------------------------------------

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

Reply via email to