php-8.0.30-src/ext/spl/tests/bug51119.phpt

26 lines
495 B
PHP

--TEST--
SPL: LimitIterator zero is valid offset
--FILE--
<?php
$array = array('a', 'b', 'c');
$arrayIterator = new ArrayIterator($array);
$limitIterator = new LimitIterator($arrayIterator, 0);
foreach ($limitIterator as $item) {
echo $item . "\n";
}
try {
$limitIterator = new LimitIterator($arrayIterator, -1);
} catch (\ValueError $e){
print $e->getMessage() . "\n";
}
?>
--EXPECT--
a
b
c
LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0