php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41692 ArrayObject shows wierd behaviour in respect to inheritance
Submitted: 2007-06-14 18:50 UTC Modified: 2007-06-27 12:42 UTC
From: toby@php.net Assigned: tony2001 (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.3 OS: Gentoo
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: toby@php.net
New email:
PHP Version: OS:

 

 [2007-06-14 18:50 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-27 12:12 UTC] tony2001@php.net
I'll commit a patch for it in a minute..
 [2007-06-27 12:42 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC