1--TEST-- 2SPL: DoublyLinkedList: Stacks 3--INI-- 4allow_call_time_pass_reference=1 5--FILE-- 6<?php 7$stack = new SplStack(); 8// errors 9try { 10 $stack->pop(); 11} catch (RuntimeException $e) { 12 echo "Exception: ".$e->getMessage()."\n"; 13} 14try { 15 $stack->shift(); 16} catch (RuntimeException $e) { 17 echo "Exception: ".$e->getMessage()."\n"; 18} 19 20// data consistency 21$a = 2; 22$stack->push($a); 23$a = 3; 24$stack->push(&$a); 25$a = 4; 26echo $stack->pop()."\n"; 27echo $stack->pop()."\n"; 28 29// peakable 30$stack->push(1); 31$stack->push(2); 32echo $stack->top()."\n"; 33 34// iterable 35foreach ($stack as $elem) { 36 echo "[$elem]\n"; 37} 38 39// countable 40$stack->push(NULL); 41$stack->push(NULL); 42echo count($stack)."\n"; 43echo $stack->count()."\n"; 44var_dump($stack->pop()); 45var_dump($stack->pop()); 46 47// clonable 48$stack->push(2); 49$stack_clone = clone $stack; 50$stack_clone->pop(); 51echo count($stack)."\n"; 52?> 53===DONE=== 54<?php exit(0); ?> 55--EXPECTF-- 56Exception: Can't pop from an empty datastructure 57Exception: Can't shift from an empty datastructure 583 592 602 61[2] 62[1] 634 644 65NULL 66NULL 673 68===DONE=== 69