xref: /PHP-8.0/ext/spl/spl_iterators.stub.php (revision fc6656e0)
1<?php
2
3/** @generate-function-entries */
4
5class EmptyIterator implements Iterator
6{
7    /** @return mixed */
8    public function current() {}
9
10    /** @return void */
11    public function next() {}
12
13    /** @return mixed */
14    public function key() {}
15
16    /** @return bool */
17    public function valid() {}
18
19    /** @return void */
20    public function rewind() {}
21}
22
23class CallbackFilterIterator extends FilterIterator
24{
25    public function __construct(Iterator $iterator, callable $callback) {}
26
27    /** @return bool */
28    public function accept() {}
29}
30
31class RecursiveCallbackFilterIterator extends CallbackFilterIterator implements RecursiveIterator
32{
33    public function __construct(RecursiveIterator $iterator, callable $callback) {}
34
35    /**
36     * @return bool
37     * @implementation-alias RecursiveFilterIterator::hasChildren
38     */
39    public function hasChildren() {}
40
41    /** @return RecursiveCallbackFilterIterator */
42    public function getChildren() {}
43}
44
45interface RecursiveIterator extends Iterator
46{
47    /** @return bool */
48    public function hasChildren();
49
50    /** @return RecursiveIterator|null */
51    public function getChildren();
52}
53
54class RecursiveIteratorIterator implements OuterIterator
55{
56    public function __construct(Traversable $iterator, int $mode = RecursiveIteratorIterator::LEAVES_ONLY, int $flags = 0) {}
57
58    /** @return void */
59    public function rewind() {}
60
61    /** @return bool */
62    public function valid() {}
63
64    /** @return mixed */
65    public function key() {}
66
67    /** @return mixed */
68    public function current() {}
69
70    /** @return void */
71    public function next() {}
72
73    /** @return int */
74    public function getDepth() {}
75
76    /** @return RecursiveIterator|null */
77    public function getSubIterator(?int $level = null) {}
78
79    /** @return RecursiveIterator */
80    public function getInnerIterator() {}
81
82    /** @return void */
83    public function beginIteration() {}
84
85    /** @return void */
86    public function endIteration() {}
87
88    /** @return bool|null */
89    public function callHasChildren() {}
90
91    /** @return RecursiveIterator|null */
92    public function callGetChildren() {}
93
94    /** @return void */
95    public function beginChildren() {}
96
97    /** @return void */
98    public function endChildren() {}
99
100    /** @return void */
101    public function nextElement() {}
102
103    /** @return void */
104    public function setMaxDepth(int $maxDepth = -1) {}
105
106    /** @return int|false */
107    public function getMaxDepth() {}
108}
109
110interface OuterIterator extends Iterator
111{
112    /** @return Iterator|null */
113    public function getInnerIterator();
114}
115
116class IteratorIterator implements OuterIterator
117{
118    public function __construct(Traversable $iterator, ?string $class = null) {}
119
120    /** @return Iterator|null */
121    public function getInnerIterator() {}
122
123    /** @return void */
124    public function rewind() {}
125
126    /** @return bool */
127    public function valid() {}
128
129    /** @return mixed */
130    public function key() {}
131
132    /** @return mixed */
133    public function current() {}
134
135    /** @return void */
136    public function next() {}
137}
138
139abstract class FilterIterator extends IteratorIterator
140{
141    /** @return bool */
142    abstract public function accept();
143
144    public function __construct(Iterator $iterator) {}
145
146    /** @return void */
147    public function rewind() {}
148
149    /** @return void */
150    public function next() {}
151}
152
153abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator
154{
155    public function __construct(RecursiveIterator $iterator) {}
156
157    /** @return bool */
158    public function hasChildren() {}
159
160    /** @return RecursiveFilterIterator|null */
161    public function getChildren() {}
162}
163
164class ParentIterator extends RecursiveFilterIterator
165{
166    public function __construct(RecursiveIterator $iterator) {}
167
168    /**
169     * @return bool
170     * @implementation-alias RecursiveFilterIterator::hasChildren
171     */
172    public function accept() {}
173}
174
175interface SeekableIterator extends Iterator
176{
177    /** @return void */
178    public function seek(int $offset);
179}
180
181class LimitIterator extends IteratorIterator
182{
183    public function __construct(Iterator $iterator, int $offset = 0, int $limit = -1) {}
184
185    /** @return void */
186    public function rewind() {}
187
188    /** @return bool */
189    public function valid() {}
190
191    /** @return void */
192    public function next() {}
193
194    /** @return int */
195    public function seek(int $offset) {}
196
197    /** @return int */
198    public function getPosition() {}
199}
200
201class CachingIterator extends IteratorIterator implements ArrayAccess, Countable
202{
203    public function __construct(Iterator $iterator, int $flags = CachingIterator::CALL_TOSTRING) {}
204
205    /** @return void */
206    public function rewind() {}
207
208    /** @return bool */
209    public function valid() {}
210
211    /** @return void */
212    public function next() {}
213
214    /** @return bool */
215    public function hasNext() {}
216
217    public function __toString(): string {}
218
219    /** @return int */
220    public function getFlags() {}
221
222    /** @return void */
223    public function setFlags(int $flags) {}
224
225    /**
226     * @param string $key
227     * @return mixed
228     */
229    public function offsetGet($key) {}
230
231    /**
232     * @param string $key
233     * @return void
234     */
235    public function offsetSet($key, mixed $value) {}
236
237    /**
238     * @param string $key
239     * @return void
240     */
241    public function offsetUnset($key) {}
242
243    /**
244     * @param string $key
245     * @return bool
246     */
247    public function offsetExists($key) {}
248
249    /** @return array */
250    public function getCache() {}
251
252    /** @return int */
253    public function count() {}
254}
255
256class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
257{
258    public function __construct(Iterator $iterator, int $flags = RecursiveCachingIterator::CALL_TOSTRING) {}
259
260    /** @return bool */
261    public function hasChildren() {}
262
263    /** @return RecursiveCachingIterator|null */
264    public function getChildren() {}
265}
266
267class NoRewindIterator extends IteratorIterator
268{
269    public function __construct(Iterator $iterator) {}
270
271    /** @return void */
272    public function rewind() {}
273
274    /** @return bool */
275    public function valid() {}
276
277    /** @return mixed */
278    public function key() {}
279
280    /** @return mixed */
281    public function current() {}
282
283    /** @return void */
284    public function next() {}
285}
286
287class AppendIterator extends IteratorIterator
288{
289    public function __construct() {}
290
291    /** @return void */
292    public function append(Iterator $iterator) {}
293
294    /** @return void */
295    public function rewind() {}
296
297    /** @return bool */
298    public function valid() {}
299
300    /** @return mixed */
301    public function current() {}
302
303    /** @return void */
304    public function next() {}
305
306    /** @return int|null */
307    public function getIteratorIndex() {}
308
309    /** @return ArrayIterator */
310    public function getArrayIterator() {}
311}
312
313class InfiniteIterator extends IteratorIterator
314{
315    public function __construct(Iterator $iterator) {}
316
317    /** @return void */
318    public function next() {}
319}
320
321class RegexIterator extends FilterIterator
322{
323    public function __construct(Iterator $iterator, string $pattern, int $mode = RegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
324
325    /** @return bool */
326    public function accept() {}
327
328    /** @return int */
329    public function getMode() {}
330
331    /** @return void */
332    public function setMode(int $mode) {}
333
334    /** @return int */
335    public function getFlags() {}
336
337    /** @return void */
338    public function setFlags(int $flags) {}
339
340    /** @return string */
341    public function getRegex() {}
342
343    /** @return int */
344    public function getPregFlags() {}
345
346    /** @return void */
347    public function setPregFlags(int $pregFlags) {}
348}
349
350class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
351{
352    public function __construct(RecursiveIterator $iterator, string $pattern, int $mode = RecursiveRegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
353
354    /** @return bool */
355    public function accept() {}
356
357    /**
358     * @return bool
359     * @implementation-alias RecursiveFilterIterator::hasChildren
360     */
361    public function hasChildren() {}
362
363    /** @return RecursiveRegexIterator */
364    public function getChildren() {}
365}
366
367class RecursiveTreeIterator extends RecursiveIteratorIterator
368{
369    /** @param RecursiveIterator|IteratorAggregate $iterator */
370    public function __construct(
371        $iterator,
372        int $flags = RecursiveTreeIterator::BYPASS_KEY,
373        int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD,
374        int $mode = RecursiveTreeIterator::SELF_FIRST
375    ) {}
376
377    /** @return mixed */
378    public function key() {}
379
380    /** @return mixed */
381    public function current() {}
382
383    /** @return string */
384    public function getPrefix() {}
385
386    /** @return void */
387    public function setPostfix(string $postfix) {}
388
389    /** @return void */
390    public function setPrefixPart(int $part, string $value) {}
391
392    /** @return string */
393    public function getEntry() {}
394
395    /** @return string */
396    public function getPostfix() {}
397}
398