1--TEST-- 2SPL: DoublyLinkedList: ArrayAccess 3--FILE-- 4<?php 5$a = new SplDoublyLinkedList(); 6$a->push(1); 7$a->push(2); 8$a->push(3); 9 10$a[] = "foo"; 11$a[3] = 4; 12 13var_dump($a[0]); 14var_dump($a[1]); 15var_dump($a[2]); 16var_dump($a[3]); 17 18echo "Unsetting..\n"; 19var_dump($a[2]); 20unset($a[2]); 21var_dump($a[2]); 22 23 24try { 25 var_dump($a["1"]); 26} catch (OutOfRangeException $e) { 27 echo "Exception: ".$e->getMessage()."\n"; 28} 29 30try { 31 var_dump($a["a"]); 32} catch (TypeError $e) { 33 echo "Exception: ".$e->getMessage()."\n"; 34} 35 36try { 37 var_dump($a["0"]); 38} catch (OutOfRangeException $e) { 39 echo "Exception: ".$e->getMessage()."\n"; 40} 41 42try { 43 var_dump($a["9"]); 44} catch (OutOfRangeException $e) { 45 echo "Exception: ".$e->getMessage()."\n"; 46} 47?> 48--EXPECT-- 49int(1) 50int(2) 51int(3) 52int(4) 53Unsetting.. 54int(3) 55int(4) 56int(2) 57Exception: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) must be of type int, string given 58int(1) 59Exception: SplDoublyLinkedList::offsetGet(): Argument #1 ($index) is out of range 60