xref: /PHP-8.2/ext/spl/spl_directory.stub.php (revision 6e87485d)
1<?php
2
3/** @generate-class-entries */
4
5/** @not-serializable */
6class SplFileInfo implements Stringable
7{
8    public function __construct(string $filename) {}
9
10    /** @tentative-return-type */
11    public function getPath(): string {}
12
13    /** @tentative-return-type */
14    public function getFilename(): string {}
15
16    /** @tentative-return-type */
17    public function getExtension(): string {}
18
19    /** @tentative-return-type */
20    public function getBasename(string $suffix = ""): string {}
21
22    /** @tentative-return-type */
23    public function getPathname(): string {}
24
25    /** @tentative-return-type */
26    public function getPerms(): int|false {}
27
28    /** @tentative-return-type */
29    public function getInode(): int|false {}
30
31    /** @tentative-return-type */
32    public function getSize(): int|false {}
33
34    /** @tentative-return-type */
35    public function getOwner(): int|false {}
36
37    /** @tentative-return-type */
38    public function getGroup(): int|false {}
39
40    /** @tentative-return-type */
41    public function getATime(): int|false {}
42
43    /** @tentative-return-type */
44    public function getMTime(): int|false {}
45
46    /** @tentative-return-type */
47    public function getCTime(): int|false {}
48
49    /** @tentative-return-type */
50    public function getType(): string|false {}
51
52    /** @tentative-return-type */
53    public function isWritable(): bool {}
54
55    /** @tentative-return-type */
56    public function isReadable(): bool {}
57
58    /** @tentative-return-type */
59    public function isExecutable(): bool {}
60
61    /** @tentative-return-type */
62    public function isFile(): bool {}
63
64    /** @tentative-return-type */
65    public function isDir(): bool {}
66
67    /** @tentative-return-type */
68    public function isLink(): bool {}
69
70    /** @tentative-return-type */
71    public function getLinkTarget(): string|false {}
72
73    /** @tentative-return-type */
74    public function getRealPath(): string|false {}
75
76    /** @tentative-return-type */
77    public function getFileInfo(?string $class = null): SplFileInfo {}
78
79    /** @tentative-return-type */
80    public function getPathInfo(?string $class = null): ?SplFileInfo {}
81
82    /**
83     * @param resource|null $context
84     * @tentative-return-type
85     */
86    public function openFile(string $mode = "r", bool $useIncludePath = false, $context = null): SplFileObject {}
87
88    /** @tentative-return-type */
89    public function setFileClass(string $class = SplFileObject::class): void {}
90
91    /** @tentative-return-type */
92    public function setInfoClass(string $class = SplFileInfo::class): void {}
93
94    /** @implementation-alias SplFileInfo::getPathname */
95    public function __toString(): string {}
96
97    /** @tentative-return-type */
98    public function __debugInfo(): array {}
99
100    /**
101     * @deprecated
102     * @tentative-return-type
103     */
104    final public function _bad_state_ex(): void {}
105}
106
107class DirectoryIterator extends SplFileInfo implements SeekableIterator
108{
109    public function __construct(string $directory) {}
110
111    /** @tentative-return-type */
112    public function getFilename(): string {}
113
114    /** @tentative-return-type */
115    public function getExtension(): string {}
116
117    /** @tentative-return-type */
118    public function getBasename(string $suffix = ""): string {}
119
120    /** @tentative-return-type */
121    public function isDot(): bool {}
122
123    /** @tentative-return-type */
124    public function rewind(): void {}
125
126    /** @tentative-return-type */
127    public function valid(): bool {}
128
129    /**
130     * @tentative-return-type
131     * @return int
132     */
133    public function key(): mixed {} // TODO change return type to string
134
135    /**
136     * @tentative-return-type
137     * @return DirectoryIterator
138     */
139    public function current(): mixed {} // TODO narrow return type
140
141    /** @tentative-return-type */
142    public function next(): void {}
143
144    /** @tentative-return-type */
145    public function seek(int $offset): void {}
146
147    /** @implementation-alias DirectoryIterator::getFilename */
148    public function __toString(): string {}
149}
150
151class FilesystemIterator extends DirectoryIterator
152{
153    /**
154     * @var int
155     * @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK
156     */
157    public const CURRENT_MODE_MASK = UNKNOWN;
158    /**
159     * @var int
160     * @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME
161     */
162    public const CURRENT_AS_PATHNAME = UNKNOWN;
163    /**
164     * @var int
165     * @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO
166     */
167    public const CURRENT_AS_FILEINFO = UNKNOWN;
168    /**
169     * @var int
170     * @cvalue SPL_FILE_DIR_CURRENT_AS_SELF
171     */
172    public const CURRENT_AS_SELF = UNKNOWN;
173    /**
174     * @var int
175     * @cvalue SPL_FILE_DIR_KEY_MODE_MASK
176     */
177    public const KEY_MODE_MASK = UNKNOWN;
178    /**
179     * @var int
180     * @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME
181     */
182    public const KEY_AS_PATHNAME = UNKNOWN;
183    /**
184     * @var int
185     * @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS
186     */
187    public const FOLLOW_SYMLINKS = UNKNOWN;
188    /**
189     * @var int
190     * @cvalue SPL_FILE_DIR_KEY_AS_FILENAME
191     */
192    public const KEY_AS_FILENAME = UNKNOWN;
193    /**
194     * @var int
195     * @cvalue SPL_FILE_NEW_CURRENT_AND_KEY
196     */
197    public const NEW_CURRENT_AND_KEY = UNKNOWN;
198    /**
199     * @var int
200     * @cvalue SPL_FILE_DIR_OTHERS_MASK
201     */
202    public const OTHER_MODE_MASK = UNKNOWN;
203    /**
204     * @var int
205     * @cvalue SPL_FILE_DIR_SKIPDOTS
206     */
207    public const SKIP_DOTS = UNKNOWN;
208    /**
209     * @var int
210     * @cvalue SPL_FILE_DIR_UNIXPATHS
211     */
212    public const UNIX_PATHS = UNKNOWN;
213
214    public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS) {}
215
216    /** @tentative-return-type */
217    public function rewind(): void {}
218
219    /** @tentative-return-type */
220    public function key(): string {}
221
222    /** @tentative-return-type */
223    public function current(): string|SplFileInfo|FilesystemIterator {}
224
225    /** @tentative-return-type */
226    public function getFlags(): int {}
227
228    /** @tentative-return-type */
229    public function setFlags(int $flags): void {}
230}
231
232class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
233{
234    public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
235
236    /** @tentative-return-type */
237    public function hasChildren(bool $allowLinks = false): bool {}
238
239    /** @tentative-return-type */
240    public function getChildren(): RecursiveDirectoryIterator {}
241
242    /** @tentative-return-type */
243    public function getSubPath(): string {}
244
245    /** @tentative-return-type */
246    public function getSubPathname(): string {}
247}
248
249#ifdef HAVE_GLOB
250class GlobIterator extends FilesystemIterator implements Countable
251{
252    public function __construct(string $pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
253
254    /** @tentative-return-type */
255    public function count(): int {}
256}
257#endif
258
259class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
260{
261    /**
262     * @var int
263     * @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE
264     */
265    public const DROP_NEW_LINE = UNKNOWN;
266    /**
267     * @var int
268     * @cvalue SPL_FILE_OBJECT_READ_AHEAD
269     */
270    public const READ_AHEAD = UNKNOWN;
271    /**
272     * @var int
273     * @cvalue SPL_FILE_OBJECT_SKIP_EMPTY
274     */
275    public const SKIP_EMPTY = UNKNOWN;
276    /**
277     * @var int
278     * @cvalue SPL_FILE_OBJECT_READ_CSV
279     */
280    public const READ_CSV = UNKNOWN;
281
282    /** @param resource|null $context */
283    public function __construct(string $filename, string $mode = "r", bool $useIncludePath = false, $context = null) {}
284
285    /** @tentative-return-type */
286    public function rewind(): void {}
287
288    /** @tentative-return-type */
289    public function eof(): bool {}
290
291    /** @tentative-return-type */
292    public function valid(): bool {}
293
294    /** @tentative-return-type */
295    public function fgets(): string {}
296
297    /** @tentative-return-type */
298    public function fread(int $length): string|false {}
299
300    /** @tentative-return-type */
301    public function fgetcsv(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false {}
302
303    /** @tentative-return-type */
304    public function fputcsv(array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\", string $eol = "\n"): int|false {}
305
306    /** @tentative-return-type */
307    public function setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): void {}
308
309    /** @tentative-return-type */
310    public function getCsvControl(): array {}
311
312    /**
313     * @param int $wouldBlock
314     * @tentative-return-type
315     */
316    public function flock(int $operation, &$wouldBlock = null): bool {}
317
318    /** @tentative-return-type */
319    public function fflush(): bool {}
320
321    /** @tentative-return-type */
322    public function ftell(): int|false {}
323
324    /** @tentative-return-type */
325    public function fseek(int $offset, int $whence = SEEK_SET): int {}
326
327    /** @tentative-return-type */
328    public function fgetc(): string|false {}
329
330    /** @tentative-return-type */
331    public function fpassthru(): int {}
332
333    /** @tentative-return-type */
334    public function fscanf(string $format, mixed &...$vars): array|int|null {}
335
336    /** @tentative-return-type */
337    public function fwrite(string $data, int $length = 0): int|false {}
338
339    /** @tentative-return-type */
340    public function fstat(): array {}
341
342    /** @tentative-return-type */
343    public function ftruncate(int $size): bool {}
344
345    /** @tentative-return-type */
346    public function current(): string|array|false {}
347
348    /** @tentative-return-type */
349    public function key(): int {}
350
351    /** @tentative-return-type */
352    public function next(): void {}
353
354    /** @tentative-return-type */
355    public function setFlags(int $flags): void {}
356
357    /** @tentative-return-type */
358    public function getFlags(): int {}
359
360    /** @tentative-return-type */
361    public function setMaxLineLen(int $maxLength): void {}
362
363    /** @tentative-return-type */
364    public function getMaxLineLen(): int {}
365
366    /** @tentative-return-type */
367    public function hasChildren(): false {}
368
369    /** @tentative-return-type */
370    public function getChildren(): null {}
371
372    /** @tentative-return-type */
373    public function seek(int $line): void {}
374
375    /**
376     * @tentative-return-type
377     * @alias SplFileObject::fgets
378     */
379    public function getCurrentLine(): string {}
380
381    public function __toString(): string {}
382}
383
384class SplTempFileObject extends SplFileObject
385{
386    public function __construct(int $maxMemory = 2 * 1024 * 1024) {}
387}
388