xref: /PHP-8.2/ext/spl/spl_iterators.stub.php (revision b73f139c)
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(): false {}
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    /**
57     * @var int
58     * @cvalue RIT_LEAVES_ONLY
59     */
60    public const LEAVES_ONLY = UNKNOWN;
61    /**
62     * @var int
63     * @cvalue RIT_SELF_FIRST
64     */
65    public const SELF_FIRST = UNKNOWN;
66    /**
67     * @var int
68     * @cvalue RIT_CHILD_FIRST
69     */
70    public const CHILD_FIRST = UNKNOWN;
71    /**
72     * @var int
73     * @cvalue RIT_CATCH_GET_CHILD
74     */
75    public const CATCH_GET_CHILD = UNKNOWN;
76
77    public function __construct(Traversable $iterator, int $mode = RecursiveIteratorIterator::LEAVES_ONLY, int $flags = 0) {}
78
79    /** @tentative-return-type */
80    public function rewind(): void {}
81
82    /** @tentative-return-type */
83    public function valid(): bool {}
84
85    /** @tentative-return-type */
86    public function key(): mixed {}
87
88    /** @tentative-return-type */
89    public function current(): mixed {}
90
91    /** @tentative-return-type */
92    public function next(): void {}
93
94    /** @tentative-return-type */
95    public function getDepth(): int {}
96
97    /** @tentative-return-type */
98    public function getSubIterator(?int $level = null): ?RecursiveIterator {}
99
100    /** @tentative-return-type */
101    public function getInnerIterator(): RecursiveIterator {}
102
103    /** @tentative-return-type */
104    public function beginIteration(): void {}
105
106    /** @tentative-return-type */
107    public function endIteration(): void {}
108
109    /** @tentative-return-type */
110    public function callHasChildren(): bool {}
111
112    /** @tentative-return-type */
113    public function callGetChildren(): ?RecursiveIterator {}
114
115    /** @tentative-return-type */
116    public function beginChildren(): void {}
117
118    /** @tentative-return-type */
119    public function endChildren(): void {}
120
121    /** @tentative-return-type */
122    public function nextElement(): void {}
123
124    /** @tentative-return-type */
125    public function setMaxDepth(int $maxDepth = -1): void {}
126
127    /** @tentative-return-type */
128    public function getMaxDepth(): int|false {}
129}
130
131interface OuterIterator extends Iterator
132{
133    /** @tentative-return-type */
134    public function getInnerIterator(): ?Iterator;
135}
136
137class IteratorIterator implements OuterIterator
138{
139    public function __construct(Traversable $iterator, ?string $class = null) {}
140
141    /** @tentative-return-type */
142    public function getInnerIterator(): ?Iterator {}
143
144    /** @tentative-return-type */
145    public function rewind(): void {}
146
147    /** @tentative-return-type */
148    public function valid(): bool {}
149
150    /** @tentative-return-type */
151    public function key(): mixed {}
152
153    /** @tentative-return-type */
154    public function current(): mixed {}
155
156    /** @tentative-return-type */
157    public function next(): void {}
158}
159
160abstract class FilterIterator extends IteratorIterator
161{
162    /** @tentative-return-type */
163    abstract public function accept(): bool;
164
165    public function __construct(Iterator $iterator) {}
166
167    /** @tentative-return-type */
168    public function rewind(): void {}
169
170    /** @tentative-return-type */
171    public function next(): void {}
172}
173
174abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator
175{
176    public function __construct(RecursiveIterator $iterator) {}
177
178    /** @tentative-return-type */
179    public function hasChildren(): bool {}
180
181    /** @tentative-return-type */
182    public function getChildren(): ?RecursiveFilterIterator {}
183}
184
185class ParentIterator extends RecursiveFilterIterator
186{
187    public function __construct(RecursiveIterator $iterator) {}
188
189    /**
190     * @tentative-return-type
191     * @implementation-alias RecursiveFilterIterator::hasChildren
192     */
193    public function accept(): bool {}
194}
195
196interface SeekableIterator extends Iterator
197{
198    /** @tentative-return-type */
199    public function seek(int $offset): void;
200}
201
202class LimitIterator extends IteratorIterator
203{
204    public function __construct(Iterator $iterator, int $offset = 0, int $limit = -1) {}
205
206    /** @tentative-return-type */
207    public function rewind(): void {}
208
209    /** @tentative-return-type */
210    public function valid(): bool {}
211
212    /** @tentative-return-type */
213    public function next(): void {}
214
215    /** @tentative-return-type */
216    public function seek(int $offset): int {}
217
218    /** @tentative-return-type */
219    public function getPosition(): int {}
220}
221
222class CachingIterator extends IteratorIterator implements ArrayAccess, Countable, Stringable
223{
224    /**
225     * @var int
226     * @cvalue CIT_CALL_TOSTRING
227     */
228    public const CALL_TOSTRING = UNKNOWN;
229    /**
230     * @var int
231     * @cvalue CIT_CATCH_GET_CHILD
232     */
233    public const CATCH_GET_CHILD = UNKNOWN;
234    /**
235     * @var int
236     * @cvalue CIT_TOSTRING_USE_KEY
237     */
238    public const TOSTRING_USE_KEY = UNKNOWN;
239    /**
240     * @var int
241     * @cvalue CIT_TOSTRING_USE_CURRENT
242     */
243    public const TOSTRING_USE_CURRENT = UNKNOWN;
244    /**
245     * @var int
246     * @cvalue CIT_TOSTRING_USE_INNER
247     */
248    public const TOSTRING_USE_INNER = UNKNOWN;
249    /**
250     * @var int
251     * @cvalue CIT_FULL_CACHE
252     */
253    public const FULL_CACHE = UNKNOWN;
254
255    public function __construct(Iterator $iterator, int $flags = CachingIterator::CALL_TOSTRING) {}
256
257    /** @tentative-return-type */
258    public function rewind(): void {}
259
260    /** @tentative-return-type */
261    public function valid(): bool {}
262
263    /** @tentative-return-type */
264    public function next(): void {}
265
266    /** @tentative-return-type */
267    public function hasNext(): bool {}
268
269    public function __toString(): string {}
270
271    /** @tentative-return-type */
272    public function getFlags(): int {}
273
274    /** @tentative-return-type */
275    public function setFlags(int $flags): void {}
276
277    /**
278     * @param string $key
279     * @tentative-return-type
280     */
281    public function offsetGet($key): mixed {}
282
283    /**
284     * @param string $key
285     * @tentative-return-type
286     */
287    public function offsetSet($key, mixed $value): void {}
288
289    /**
290     * @param string $key
291     * @tentative-return-type
292     */
293    public function offsetUnset($key): void {}
294
295    /**
296     * @param string $key
297     * @tentative-return-type
298     */
299    public function offsetExists($key): bool {}
300
301    /** @tentative-return-type */
302    public function getCache(): array {}
303
304    /** @tentative-return-type */
305    public function count(): int {}
306}
307
308class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
309{
310    public function __construct(Iterator $iterator, int $flags = RecursiveCachingIterator::CALL_TOSTRING) {}
311
312    /** @tentative-return-type */
313    public function hasChildren(): bool {}
314
315    /** @tentative-return-type */
316    public function getChildren(): ?RecursiveCachingIterator {}
317}
318
319class NoRewindIterator extends IteratorIterator
320{
321    public function __construct(Iterator $iterator) {}
322
323    /** @tentative-return-type */
324    public function rewind(): void {}
325
326    /** @tentative-return-type */
327    public function valid(): bool {}
328
329    /** @tentative-return-type */
330    public function key(): mixed {}
331
332    /** @tentative-return-type */
333    public function current(): mixed {}
334
335    /** @tentative-return-type */
336    public function next(): void {}
337}
338
339class AppendIterator extends IteratorIterator
340{
341    public function __construct() {}
342
343    /** @tentative-return-type */
344    public function append(Iterator $iterator): void {}
345
346    /** @tentative-return-type */
347    public function rewind(): void {}
348
349    /** @tentative-return-type */
350    public function valid(): bool {}
351
352    /** @tentative-return-type */
353    public function current(): mixed {}
354
355    /** @tentative-return-type */
356    public function next(): void {}
357
358    /** @tentative-return-type */
359    public function getIteratorIndex(): ?int {}
360
361    /** @tentative-return-type */
362    public function getArrayIterator(): ArrayIterator {}
363}
364
365class InfiniteIterator extends IteratorIterator
366{
367    public function __construct(Iterator $iterator) {}
368
369    /** @tentative-return-type */
370    public function next(): void {}
371}
372
373class RegexIterator extends FilterIterator
374{
375    /**
376     * @var int
377     * @cvalue REGIT_USE_KEY
378     */
379    public const USE_KEY = UNKNOWN;
380    /**
381     * @var int
382     * @cvalue REGIT_INVERTED
383     */
384    public const INVERT_MATCH = UNKNOWN;
385    /**
386     * @var int
387     * @cvalue REGIT_MODE_MATCH
388     */
389    public const MATCH = UNKNOWN;
390    /**
391     * @var int
392     * @cvalue REGIT_MODE_GET_MATCH
393     */
394    public const GET_MATCH = UNKNOWN;
395    /**
396     * @var int
397     * @cvalue REGIT_MODE_ALL_MATCHES
398     */
399    public const ALL_MATCHES = UNKNOWN;
400    /**
401     * @var int
402     * @cvalue REGIT_MODE_SPLIT
403     */
404    public const SPLIT = UNKNOWN;
405    /**
406     * @var int
407     * @cvalue REGIT_MODE_REPLACE
408     */
409    public const REPLACE = UNKNOWN;
410
411    public ?string $replacement = null;
412
413    public function __construct(Iterator $iterator, string $pattern, int $mode = RegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
414
415    /** @tentative-return-type */
416    public function accept(): bool {}
417
418    /** @tentative-return-type */
419    public function getMode(): int {}
420
421    /** @tentative-return-type */
422    public function setMode(int $mode): void {}
423
424    /** @tentative-return-type */
425    public function getFlags(): int {}
426
427    /** @tentative-return-type */
428    public function setFlags(int $flags): void {}
429
430    /** @tentative-return-type */
431    public function getRegex(): string {}
432
433    /** @tentative-return-type */
434    public function getPregFlags(): int {}
435
436    /** @tentative-return-type */
437    public function setPregFlags(int $pregFlags): void {}
438}
439
440class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
441{
442    public function __construct(RecursiveIterator $iterator, string $pattern, int $mode = RecursiveRegexIterator::MATCH, int $flags = 0, int $pregFlags = 0) {}
443
444    /** @tentative-return-type */
445    public function accept(): bool {}
446
447    /**
448     * @tentative-return-type
449     * @implementation-alias RecursiveFilterIterator::hasChildren
450     */
451    public function hasChildren(): bool {}
452
453    /** @tentative-return-type */
454    public function getChildren(): RecursiveRegexIterator {}
455}
456
457class RecursiveTreeIterator extends RecursiveIteratorIterator
458{
459    /**
460     * @var int
461     * @cvalue RTIT_BYPASS_CURRENT
462     */
463    public const BYPASS_CURRENT = UNKNOWN;
464    /**
465     * @var int
466     * @cvalue RTIT_BYPASS_KEY
467     */
468    public const BYPASS_KEY = UNKNOWN;
469    /** @var int */
470    public const PREFIX_LEFT = 0;
471    /** @var int */
472    public const PREFIX_MID_HAS_NEXT = 1;
473    /** @var int */
474    public const PREFIX_MID_LAST = 2;
475    /** @var int */
476    public const PREFIX_END_HAS_NEXT = 3;
477    /** @var int */
478    public const PREFIX_END_LAST = 4;
479    /** @var int */
480    public const PREFIX_RIGHT = 5;
481
482    /** @param RecursiveIterator|IteratorAggregate $iterator */
483    public function __construct(
484        $iterator,
485        int $flags = RecursiveTreeIterator::BYPASS_KEY,
486        int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD,
487        int $mode = RecursiveTreeIterator::SELF_FIRST
488    ) {}
489
490    /** @tentative-return-type */
491    public function key(): mixed {}
492
493    /** @tentative-return-type */
494    public function current(): mixed {}
495
496    /** @tentative-return-type */
497    public function getPrefix(): string {}
498
499    /** @tentative-return-type */
500    public function setPostfix(string $postfix): void {}
501
502    /** @tentative-return-type */
503    public function setPrefixPart(int $part, string $value): void {}
504
505    /** @tentative-return-type */
506    public function getEntry(): string {}
507
508    /** @tentative-return-type */
509    public function getPostfix(): string {}
510}
511