ID: 48052 Updated by: col...@php.net Reported By: ralph at smashlabs dot com -Status: Assigned +Status: Bogus Bug Type: SPL related Operating System: * PHP Version: 5.3, 6CVS (2009-04-25) Assigned To: colder New Comment:
The reason is that setIteratorMode replaces the iterator flags entirely, so you need to specify the order of iteration as well if you want to change the KEEP/DELETE. Since you use a stack, simply use: SplDoublyLinkedList:: IT_MODE_DELETE | SplDoublyLinkedList::IT_MODE_LIFO Previous Comments: ------------------------------------------------------------------------ [2009-04-22 16:50:24] ralph at smashlabs dot com Description: ------------ Attempting to change the IteratorMode throws an exception. The is probably due to the code that changes the LIFO/FIFO ordering that is also settable via the inherited method of SplDoublyLinkedList::setIteratorMode(). Reproduce code: --------------- <?php $s = new SPLStack(); $s->setIteratorMode(SplDoublyLinkedList::IT_MODE_DELETE); Expected result: ---------------- Do not throw exception on the following use cases: ->setIteratorMode(SplDoublyLinkedList::IT_MODE_DELETE) ->setIteratorMode(SplDoublyLinkedList::IT_MODE_KEEP) Actual result: -------------- PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen' in path/to/test-splstack.php:4 Stack trace: #0 path/to/test-splstack.php(4): SplDoublyLinkedList->setIteratorMode(1) #1 {main} thrown in path/to/test-splstack.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48052&edit=1