2004-11-01 03:49:18 +08:00
|
|
|
--TEST--
|
|
|
|
SPL: InfiniteIterator
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class ArrayIteratorEx extends ArrayIterator
|
|
|
|
{
|
2020-02-04 05:52:20 +08:00
|
|
|
function rewind()
|
|
|
|
{
|
|
|
|
echo __METHOD__ . "\n";
|
|
|
|
parent::rewind();
|
|
|
|
}
|
|
|
|
function valid()
|
|
|
|
{
|
|
|
|
echo __METHOD__ . "\n";
|
|
|
|
return parent::valid();
|
|
|
|
}
|
|
|
|
function current()
|
|
|
|
{
|
|
|
|
echo __METHOD__ . "\n";
|
|
|
|
return parent::current();
|
|
|
|
}
|
|
|
|
function key()
|
|
|
|
{
|
|
|
|
echo __METHOD__ . "\n";
|
|
|
|
return parent::key();
|
|
|
|
}
|
|
|
|
function next()
|
|
|
|
{
|
|
|
|
echo __METHOD__ . "\n";
|
|
|
|
parent::next();
|
|
|
|
}
|
2004-11-01 03:49:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$it = new InfiniteIterator(new ArrayIteratorEx(range(0,2)));
|
|
|
|
|
|
|
|
$pos =0;
|
|
|
|
|
|
|
|
foreach ($it as $v) {
|
2020-02-04 05:52:20 +08:00
|
|
|
var_dump($v);
|
|
|
|
if ($pos++ > 5) {
|
|
|
|
break;
|
|
|
|
}
|
2004-11-01 03:49:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
ArrayIteratorEx::rewind
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(0)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(1)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(2)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::rewind
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(0)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(1)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(2)
|
|
|
|
ArrayIteratorEx::next
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::rewind
|
|
|
|
ArrayIteratorEx::valid
|
|
|
|
ArrayIteratorEx::current
|
|
|
|
ArrayIteratorEx::key
|
|
|
|
int(0)
|