php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37623 offsetUnset() on foreached arrayObject item throw E_NOTICE
Submitted: 2006-05-29 09:27 UTC Modified: 2006-05-29 18:29 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: sperson at lfdj dot com Assigned: helly (profile)
Status: Not a bug Package: SPL related
PHP Version: 5.* 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sperson at lfdj dot com
New email:
PHP Version: OS:

 

 [2006-05-29 09:27 UTC] sperson at lfdj dot com
Description:
------------
When we do a foreach on an arrayObject, and we want to unset some item from the loop a NOTICE is thrown.

Don't know if this is the intended behaviour but in case of doubt I prefer to submit.

Reproduce code:
---------------
$coll = new ArrayObject();
$coll->append(new stdClass());
foreach ($coll as $index => $item) {
	$coll->offsetUnset($index);
}

Expected result:
----------------
nothing

Actual result:
--------------
Notice: main() [function.main]: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in index.php on line 7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-29 09:48 UTC] mike@php.net
AFAICT this is intended.
 [2006-05-29 18:29 UTC] helly@php.net
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

The notice means that foreach rewinds or moves to its end. Whatever the ArrayIterator decides.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC