1--TEST-- 2SPL: DoublyLinkedList: insert operations 3--FILE-- 4<?php 5$dll = new SplDoublyLinkedList(); 6// errors 7try { 8 $dll->add(2,5); 9} catch (OutOfRangeException $e) { 10 echo "Exception: ".$e->getMessage()."\n"; 11} 12 13$dll->add(0,6); // 6 14$dll->add(0,3); // 3 6 15// Insert in the middle of the DLL 16$dll->add(1,4); // 3 4 6 17$dll->add(2,5); // 3 4 5 6 18$dll->unshift(2); // 2 3 5 4 6 19// Insert at the beginning and end of the DLL 20$dll->add(0,1); // 1 2 3 4 5 6 21$dll->add(6,7); // 1 2 3 4 5 6 7 22 23echo count($dll)."\n"; 24 25echo $dll->pop()."\n"; 26echo $dll->pop()."\n"; 27echo $dll->pop()."\n"; 28echo $dll->pop()."\n"; 29echo $dll->pop()."\n"; 30echo $dll->pop()."\n"; 31echo $dll->pop()."\n"; 32 33// Test refcounted value 34$str = "foo"; 35$str .= "bar"; 36$dll->add(0, $str); 37$dll->add(0, $str); 38var_dump($dll->shift()); 39var_dump($dll->shift()); 40 41?> 42--EXPECT-- 43Exception: SplDoublyLinkedList::add(): Argument #1 ($index) is out of range 447 457 466 475 484 493 502 511 52string(6) "foobar" 53string(6) "foobar" 54