xref: /PHP-5.5/ext/spl/tests/iterator_008.phpt (revision 610c7fbe)
1--TEST--
2SPL: InfiniteIterator
3--FILE--
4<?php
5
6class ArrayIteratorEx extends ArrayIterator
7{
8	function rewind()
9	{
10		echo __METHOD__ . "\n";
11		parent::rewind();
12	}
13	function valid()
14	{
15		echo __METHOD__ . "\n";
16		return parent::valid();
17	}
18	function current()
19	{
20		echo __METHOD__ . "\n";
21		return parent::current();
22	}
23	function key()
24	{
25		echo __METHOD__ . "\n";
26		return parent::key();
27	}
28	function next()
29	{
30		echo __METHOD__ . "\n";
31		parent::next();
32	}
33}
34
35$it = new InfiniteIterator(new ArrayIteratorEx(range(0,2)));
36
37$pos =0;
38
39foreach ($it as $v) {
40	var_dump($v);
41	if ($pos++ > 5) {
42		break;
43	}
44}
45
46?>
47===DONE===
48<?php exit(0); ?>
49--EXPECT--
50ArrayIteratorEx::rewind
51ArrayIteratorEx::valid
52ArrayIteratorEx::current
53ArrayIteratorEx::key
54int(0)
55ArrayIteratorEx::next
56ArrayIteratorEx::valid
57ArrayIteratorEx::current
58ArrayIteratorEx::key
59int(1)
60ArrayIteratorEx::next
61ArrayIteratorEx::valid
62ArrayIteratorEx::current
63ArrayIteratorEx::key
64int(2)
65ArrayIteratorEx::next
66ArrayIteratorEx::valid
67ArrayIteratorEx::rewind
68ArrayIteratorEx::valid
69ArrayIteratorEx::current
70ArrayIteratorEx::key
71int(0)
72ArrayIteratorEx::next
73ArrayIteratorEx::valid
74ArrayIteratorEx::current
75ArrayIteratorEx::key
76int(1)
77ArrayIteratorEx::next
78ArrayIteratorEx::valid
79ArrayIteratorEx::current
80ArrayIteratorEx::key
81int(2)
82ArrayIteratorEx::next
83ArrayIteratorEx::valid
84ArrayIteratorEx::rewind
85ArrayIteratorEx::valid
86ArrayIteratorEx::current
87ArrayIteratorEx::key
88int(0)
89===DONE===
90