|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36941 ArrayIterator does not clone itself
Submitted: 2006-04-01 16:29 UTC Modified: 2006-04-04 19:53 UTC
From: ce at netage dot bg Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.1.3RC2 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ce at netage dot bg
New email:
PHP Version: OS:


 [2006-04-01 16:29 UTC] ce at netage dot bg
ArrayIterator does not clone itself

Reproduce code:
$a = new ArrayIterator();
$a[] = 1;

$b = clone $a;

var_dump($a[0], $b[0]);
$b[0] = $b[0] + 1;
var_dump($a[0], $b[0]);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-01 21:17 UTC]
Marcus, could you plz look at it?
 [2006-04-02 17:11 UTC]
Fixed most of the issue in head but not like you expected to.

If you clone an ArrayIterator you also clone its reference thus the described behavior below is correct.

If you clone an ArrayObject you clone the array, too. However the behavior is not completely correct yet.
 [2006-04-04 19:53 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC