1--TEST--
2Iteration over SplDoublyLinkedList via 'foreach' does not change direction partway
3--FILE--
4<?php
5
6$list = new SplDoublyLinkedList();
7$list->push(1);
8$list->push(2);
9$list->push(3);
10
11/* SplDoublyLinkedList would previously check the iteration mode *each time*
12   it would advance to the next item in a 'foreach' loop
13   This meant that it could move forward, then backward, then forward if the
14   iteration mode was changed in the middle of a loop */
15
16$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
17foreach ($list as $item) {
18  $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
19  echo $item, "\n";
20}
21
22echo "***\n";
23
24$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
25foreach ($list as $item) {
26  $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
27  echo $item, "\n";
28}
29
30
31?>
32--EXPECT--
331
342
353
36***
373
382
391
40