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