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