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