#37623 [Asn->Bgs]: offsetUnset() on foreached arrayObject item throw E_NOTICE

From: Date: Mon, 29 May 2006 18:29:25 +0000
Subject: #37623 [Asn->Bgs]: offsetUnset() on foreached arrayObject item throw E_NOTICE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97760@lists.php.net to get a copy of this message
ID: 37623 Updated by: helly@php.net Reported By: sperson at lfdj dot com -Status: Assigned +Status: Bogus Bug Type: SPL related -Operating System: +Operating System: * -PHP Version: 5.1.4 +PHP Version: 5.* Assigned To: helly New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2006-05-29 09:48:01] mike@php.net AFAICT this is intended. ------------------------------------------------------------------------ [2006-05-29 09:27:32] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37623&edit=1

« previous php.bugs (#97760) next »