PHP stack with SplStack

Code
<?php

// LIFO by default
$list = new SplStack();

try {
    
// unlike SplDoublyLinkedList you can't change direction
    
$list->setIteratorMode(SplStack::IT_MODE_FIFO);
}
catch(
RuntimeException $e) {
    echo 
$e->getMessage() . PHP_EOL;
}

try {
    
// but you can't change KEEP to DELETE either
    // Is the PHP documentation wrong?
    
$list->setIteratorMode(SplStack::IT_MODE_DELETE);
}
catch(
RuntimeException $e) {
    echo 
$e->getMessage() . PHP_EOL;
}

// LIFO needs to be readded again to prevent an exception
$list->setIteratorMode(
    
SplStack::IT_MODE_LIFO |
    
SplStack::IT_MODE_DELETE
);


// adding elements with push or unshift
$list->push(1);
$list->push(10);
$list->push(100);

foreach (
$list as $element) {
    echo 
$element PHP_EOL;
}

echo 
'count: ' count($list);
Result
Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
100
10
1
count: 0
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8