Annotation of embedaddon/php/ext/spl/tests/iterator_007.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: NoRewindIterator
3: --FILE--
4: <?php
5:
6: class 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: class NoRewindIteratorEx extends NoRewindIterator
36: {
37: function rewind()
38: {
39: echo __METHOD__ . "\n";
40: parent::rewind();
41: }
42: function valid()
43: {
44: echo __METHOD__ . "\n";
45: return parent::valid();
46: }
47: function current()
48: {
49: echo __METHOD__ . "\n";
50: return parent::current();
51: }
52: function key()
53: {
54: echo __METHOD__ . "\n";
55: return parent::key();
56: }
57: function next()
58: {
59: echo __METHOD__ . "\n";
60: parent::next();
61: }
62: }
63:
64: $it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3)));
65:
66: echo "===0===\n";
67: foreach ($it->getInnerIterator() as $v) {
68: var_dump($v);
69: }
70:
71: echo "===1===\n";
72: foreach ($it as $v) {
73: var_dump($v);
74: }
75:
76: $pos =0;
77:
78: $it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3)));
79:
80: echo "===2===\n";
81: foreach ($it as $v) {
82: var_dump($v);
83: if ($pos++ > 1) {
84: break;
85: }
86: }
87:
88: echo "===3===\n";
89: foreach ($it as $v) {
90: var_dump($v);
91: }
92:
93: echo "===4===\n";
94: foreach ($it as $v) {
95: var_dump($v);
96: }
97: ?>
98: ===DONE===
99: <?php exit(0); ?>
100: --EXPECT--
101: ===0===
102: ArrayIteratorEx::rewind
103: ArrayIteratorEx::valid
104: ArrayIteratorEx::current
105: int(0)
106: ArrayIteratorEx::next
107: ArrayIteratorEx::valid
108: ArrayIteratorEx::current
109: int(1)
110: ArrayIteratorEx::next
111: ArrayIteratorEx::valid
112: ArrayIteratorEx::current
113: int(2)
114: ArrayIteratorEx::next
115: ArrayIteratorEx::valid
116: ArrayIteratorEx::current
117: int(3)
118: ArrayIteratorEx::next
119: ArrayIteratorEx::valid
120: ===1===
121: NoRewindIteratorEx::rewind
122: NoRewindIteratorEx::valid
123: ArrayIteratorEx::valid
124: ===2===
125: NoRewindIteratorEx::rewind
126: NoRewindIteratorEx::valid
127: ArrayIteratorEx::valid
128: NoRewindIteratorEx::current
129: ArrayIteratorEx::current
130: int(0)
131: NoRewindIteratorEx::next
132: ArrayIteratorEx::next
133: NoRewindIteratorEx::valid
134: ArrayIteratorEx::valid
135: NoRewindIteratorEx::current
136: ArrayIteratorEx::current
137: int(1)
138: NoRewindIteratorEx::next
139: ArrayIteratorEx::next
140: NoRewindIteratorEx::valid
141: ArrayIteratorEx::valid
142: NoRewindIteratorEx::current
143: ArrayIteratorEx::current
144: int(2)
145: ===3===
146: NoRewindIteratorEx::rewind
147: NoRewindIteratorEx::valid
148: ArrayIteratorEx::valid
149: NoRewindIteratorEx::current
150: int(2)
151: NoRewindIteratorEx::next
152: ArrayIteratorEx::next
153: NoRewindIteratorEx::valid
154: ArrayIteratorEx::valid
155: NoRewindIteratorEx::current
156: ArrayIteratorEx::current
157: int(3)
158: NoRewindIteratorEx::next
159: ArrayIteratorEx::next
160: NoRewindIteratorEx::valid
161: ArrayIteratorEx::valid
162: ===4===
163: NoRewindIteratorEx::rewind
164: NoRewindIteratorEx::valid
165: ArrayIteratorEx::valid
166: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>