1<?php 2 3/** 4 * @see https://github.com/laminas/laminas-stdlib for the canonical source repository 5 * @copyright https://github.com/laminas/laminas-stdlib/blob/master/COPYRIGHT.md 6 * @license https://github.com/laminas/laminas-stdlib/blob/master/LICENSE.md New BSD License 7 */ 8 9namespace Laminas\Stdlib; 10 11use ArrayIterator; 12use ArrayObject as PhpArrayObject; 13 14/** 15 * ArrayObject that acts as a stack with regards to iteration 16 */ 17class ArrayStack extends PhpArrayObject 18{ 19 /** 20 * Retrieve iterator 21 * 22 * Retrieve an array copy of the object, reverse its order, and return an 23 * ArrayIterator with that reversed array. 24 * 25 * @return ArrayIterator 26 */ 27 public function getIterator() 28 { 29 $array = $this->getArrayCopy(); 30 return new ArrayIterator(array_reverse($array)); 31 } 32} 33