Annotation of embedaddon/php/ext/spl/tests/iterator_052.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: RegexIterator::ALL_MATCHES
3: --FILE--
4: <?php
5:
6: class MyRegexIterator extends RegexIterator
7: {
8: public $uk, $re;
9:
10: function __construct($it, $re, $mode, $flags = 0)
11: {
12: $this->uk = $flags & self::USE_KEY;
13: $this->re = $re;
14: parent::__construct($it, $re, $mode, $flags);
15: }
16:
17: function show()
18: {
19: foreach($this as $k => $v)
20: {
21: var_dump($k);
22: var_dump($v);
23: }
24: }
25:
26: function accept()
27: {
28: @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub);
29: $ret = parent::accept();
30: var_dump($sub == $this->current());
31: return $ret;
32: }
33: }
34:
35: $ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
36: $it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES);
37: $it->show();
38:
39: $it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES);
40: $it->show();
41:
42: var_dump($ar);
43:
44: ?>
45: ===DONE===
46: <?php exit(0); ?>
47: --EXPECTF--
48: bool(true)
49: int(0)
50: array(3) {
51: [0]=>
52: array(0) {
53: }
54: [1]=>
55: array(0) {
56: }
57: [2]=>
58: array(0) {
59: }
60: }
61: bool(true)
62: int(1)
63: array(3) {
64: [0]=>
65: array(1) {
66: [0]=>
67: string(3) "1,2"
68: }
69: [1]=>
70: array(1) {
71: [0]=>
72: string(1) "1"
73: }
74: [2]=>
75: array(1) {
76: [0]=>
77: string(1) "2"
78: }
79: }
80: bool(true)
81: int(2)
82: array(3) {
83: [0]=>
84: array(1) {
85: [0]=>
86: string(3) "1,2"
87: }
88: [1]=>
89: array(1) {
90: [0]=>
91: string(1) "1"
92: }
93: [2]=>
94: array(1) {
95: [0]=>
96: string(1) "2"
97: }
98: }
99: bool(true)
100: int(3)
101: array(3) {
102: [0]=>
103: array(0) {
104: }
105: [1]=>
106: array(0) {
107: }
108: [2]=>
109: array(0) {
110: }
111: }
112: bool(true)
113: int(4)
114: array(3) {
115: [0]=>
116: array(0) {
117: }
118: [1]=>
119: array(0) {
120: }
121: [2]=>
122: array(0) {
123: }
124: }
125: bool(true)
126: int(5)
127: array(3) {
128: [0]=>
129: array(0) {
130: }
131: [1]=>
132: array(0) {
133: }
134: [2]=>
135: array(0) {
136: }
137: }
138: bool(true)
139: int(6)
140: array(3) {
141: [0]=>
142: array(0) {
143: }
144: [1]=>
145: array(0) {
146: }
147: [2]=>
148: array(0) {
149: }
150: }
151: bool(true)
152: int(7)
153: array(3) {
154: [0]=>
155: array(0) {
156: }
157: [1]=>
158: array(0) {
159: }
160: [2]=>
161: array(0) {
162: }
163: }
164: bool(true)
165: int(8)
166: array(3) {
167: [0]=>
168: array(0) {
169: }
170: [1]=>
171: array(0) {
172: }
173: [2]=>
174: array(0) {
175: }
176: }
177: bool(true)
178: int(0)
179: array(2) {
180: [0]=>
181: array(1) {
182: [0]=>
183: string(1) "1"
184: }
185: [1]=>
186: array(1) {
187: [0]=>
188: string(1) "1"
189: }
190: }
191: bool(true)
192: int(1)
193: array(2) {
194: [0]=>
195: array(2) {
196: [0]=>
197: string(1) "1"
198: [1]=>
199: string(1) "2"
200: }
201: [1]=>
202: array(2) {
203: [0]=>
204: string(1) "1"
205: [1]=>
206: string(1) "2"
207: }
208: }
209: bool(true)
210: int(2)
211: array(2) {
212: [0]=>
213: array(3) {
214: [0]=>
215: string(1) "1"
216: [1]=>
217: string(1) "2"
218: [2]=>
219: string(1) "3"
220: }
221: [1]=>
222: array(3) {
223: [0]=>
224: string(1) "1"
225: [1]=>
226: string(1) "2"
227: [2]=>
228: string(1) "3"
229: }
230: }
231: bool(true)
232: int(3)
233: array(2) {
234: [0]=>
235: array(0) {
236: }
237: [1]=>
238: array(0) {
239: }
240: }
241: bool(true)
242: int(4)
243: array(2) {
244: [0]=>
245: array(0) {
246: }
247: [1]=>
248: array(0) {
249: }
250: }
251: bool(true)
252: int(5)
253: array(2) {
254: [0]=>
255: array(0) {
256: }
257: [1]=>
258: array(0) {
259: }
260: }
261: bool(true)
262: int(6)
263: array(2) {
264: [0]=>
265: array(0) {
266: }
267: [1]=>
268: array(0) {
269: }
270: }
271: bool(true)
272: int(7)
273: array(2) {
274: [0]=>
275: array(0) {
276: }
277: [1]=>
278: array(0) {
279: }
280: }
281: bool(true)
282: int(8)
283: array(2) {
284: [0]=>
285: array(0) {
286: }
287: [1]=>
288: array(0) {
289: }
290: }
291: object(ArrayIterator)#%d (1) {
292: ["storage":"ArrayIterator":private]=>
293: array(9) {
294: [0]=>
295: %s(1) "1"
296: [1]=>
297: %s(3) "1,2"
298: [2]=>
299: %s(5) "1,2,3"
300: [3]=>
301: %s(0) ""
302: [4]=>
303: NULL
304: [5]=>
305: array(0) {
306: }
307: [6]=>
308: %s(6) "FooBar"
309: [7]=>
310: %s(1) ","
311: [8]=>
312: %s(2) ",,"
313: }
314: }
315: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>