#41692 [Opn->Asn]: ArrayObject shows wierd behaviour in respect to inheritance

From: Date: Wed, 27 Jun 2007 11:55:44 +0000
Subject: #41692 [Opn->Asn]: ArrayObject shows wierd behaviour in respect to inheritance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-114326@lists.php.net to get a copy of this message
 ID:               41692
 Updated by:       sniper@php.net
 Reported By:      toby@php.net
-Status:           Open
+Status:           Assigned
 Bug Type:         SPL related
 Operating System: Gentoo
 PHP Version:      5.2.3
 Assigned To:      helly


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

[2007-06-14 18:50:19] toby@php.net

Description:
------------
See the code for best description, what happens...

Reproduce code:
---------------
class Bar extends ArrayObject {
    private $foo = array( 1, 2, 3 );
    function __construct() 
    {
       parent::__construct($this->foo);
    }
}

$foo = new Bar();
var_dump($foo);
object(Bar)#1 (3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

$foo['foo'] = 23;
var_dump($foo);
object(Bar)#1 (4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  ["foo"]=>
  int(23)
}

$bar = new Bar();
var_dump($bar);
object(Bar)#2 (4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  ["foo"]=>
  int(23)
}

Expected result:
----------------
The second instance should have a clean array instead of the array
which the first one got.



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


-- 
Edit this bug report at http://bugs.php.net/?id=41692&edit=1


Thread (4 messages)

« previous php.bugs (#114326) next »