xref: /php-src/ext/spl/spl_directory.stub.php (revision 2501cad2)
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    #[\Deprecated(since: '8.2')]
101    final public function _bad_state_ex(): void {}
102}
103
104class DirectoryIterator extends SplFileInfo implements SeekableIterator
105{
106    public function __construct(string $directory) {}
107
108    /** @tentative-return-type */
109    public function getFilename(): string {}
110
111    /** @tentative-return-type */
112    public function getExtension(): string {}
113
114    /** @tentative-return-type */
115    public function getBasename(string $suffix = ""): string {}
116
117    /** @tentative-return-type */
118    public function isDot(): bool {}
119
120    /** @tentative-return-type */
121    public function rewind(): void {}
122
123    /** @tentative-return-type */
124    public function valid(): bool {}
125
126    /**
127     * @tentative-return-type
128     * @return int
129     */
130    public function key(): mixed {} // TODO change return type to string
131
132    /**
133     * @tentative-return-type
134     * @return DirectoryIterator
135     */
136    public function current(): mixed {} // TODO narrow return type
137
138    /** @tentative-return-type */
139    public function next(): void {}
140
141    /** @tentative-return-type */
142    public function seek(int $offset): void {}
143
144    /** @implementation-alias DirectoryIterator::getFilename */
145    public function __toString(): string {}
146}
147
148class FilesystemIterator extends DirectoryIterator
149{
150    /** @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK */
151    public const int CURRENT_MODE_MASK = UNKNOWN;
152    /** @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME */
153    public const int CURRENT_AS_PATHNAME = UNKNOWN;
154    /** @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO */
155    public const int CURRENT_AS_FILEINFO = UNKNOWN;
156    /** @cvalue SPL_FILE_DIR_CURRENT_AS_SELF */
157    public const int CURRENT_AS_SELF = UNKNOWN;
158    /** @cvalue SPL_FILE_DIR_KEY_MODE_MASK */
159    public const int KEY_MODE_MASK = UNKNOWN;
160    /** @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME */
161    public const int KEY_AS_PATHNAME = UNKNOWN;
162    /** @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS */
163    public const int FOLLOW_SYMLINKS = UNKNOWN;
164    /** @cvalue SPL_FILE_DIR_KEY_AS_FILENAME */
165    public const int KEY_AS_FILENAME = UNKNOWN;
166    /** @cvalue SPL_FILE_NEW_CURRENT_AND_KEY */
167    public const int NEW_CURRENT_AND_KEY = UNKNOWN;
168    /** @cvalue SPL_FILE_DIR_OTHERS_MASK */
169    public const int OTHER_MODE_MASK = UNKNOWN;
170    /** @cvalue SPL_FILE_DIR_SKIPDOTS */
171    public const int SKIP_DOTS = UNKNOWN;
172    /** @cvalue SPL_FILE_DIR_UNIXPATHS */
173    public const int UNIX_PATHS = UNKNOWN;
174
175    public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS) {}
176
177    /** @tentative-return-type */
178    public function rewind(): void {}
179
180    /** @tentative-return-type */
181    public function key(): string {}
182
183    /** @tentative-return-type */
184    public function current(): string|SplFileInfo|FilesystemIterator {}
185
186    /** @tentative-return-type */
187    public function getFlags(): int {}
188
189    /** @tentative-return-type */
190    public function setFlags(int $flags): void {}
191}
192
193class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
194{
195    public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
196
197    /** @tentative-return-type */
198    public function hasChildren(bool $allowLinks = false): bool {}
199
200    /** @tentative-return-type */
201    public function getChildren(): RecursiveDirectoryIterator {}
202
203    /** @tentative-return-type */
204    public function getSubPath(): string {}
205
206    /** @tentative-return-type */
207    public function getSubPathname(): string {}
208}
209
210#ifdef HAVE_GLOB
211class GlobIterator extends FilesystemIterator implements Countable
212{
213    public function __construct(string $pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
214
215    /** @tentative-return-type */
216    public function count(): int {}
217}
218#endif
219
220class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
221{
222    /** @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE */
223    public const int DROP_NEW_LINE = UNKNOWN;
224    /** @cvalue SPL_FILE_OBJECT_READ_AHEAD */
225    public const int READ_AHEAD = UNKNOWN;
226    /** @cvalue SPL_FILE_OBJECT_SKIP_EMPTY */
227    public const int SKIP_EMPTY = UNKNOWN;
228    /** @cvalue SPL_FILE_OBJECT_READ_CSV */
229    public const int READ_CSV = UNKNOWN;
230
231    /** @param resource|null $context */
232    public function __construct(string $filename, string $mode = "r", bool $useIncludePath = false, $context = null) {}
233
234    /** @tentative-return-type */
235    public function rewind(): void {}
236
237    /** @tentative-return-type */
238    public function eof(): bool {}
239
240    /** @tentative-return-type */
241    public function valid(): bool {}
242
243    /** @tentative-return-type */
244    public function fgets(): string {}
245
246    /** @tentative-return-type */
247    public function fread(int $length): string|false {}
248
249    /** @tentative-return-type */
250    public function fgetcsv(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false {}
251
252    /** @tentative-return-type */
253    public function fputcsv(array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\", string $eol = "\n"): int|false {}
254
255    /** @tentative-return-type */
256    public function setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): void {}
257
258    /** @tentative-return-type */
259    public function getCsvControl(): array {}
260
261    /**
262     * @param int $wouldBlock
263     * @tentative-return-type
264     */
265    public function flock(int $operation, &$wouldBlock = null): bool {}
266
267    /** @tentative-return-type */
268    public function fflush(): bool {}
269
270    /** @tentative-return-type */
271    public function ftell(): int|false {}
272
273    /** @tentative-return-type */
274    public function fseek(int $offset, int $whence = SEEK_SET): int {}
275
276    /** @tentative-return-type */
277    public function fgetc(): string|false {}
278
279    /** @tentative-return-type */
280    public function fpassthru(): int {}
281
282    /** @tentative-return-type */
283    public function fscanf(string $format, mixed &...$vars): array|int|null {}
284
285    /** @tentative-return-type */
286    public function fwrite(string $data, int $length = 0): int|false {}
287
288    /** @tentative-return-type */
289    public function fstat(): array {}
290
291    /** @tentative-return-type */
292    public function ftruncate(int $size): bool {}
293
294    /** @tentative-return-type */
295    public function current(): string|array|false {}
296
297    /** @tentative-return-type */
298    public function key(): int {}
299
300    /** @tentative-return-type */
301    public function next(): void {}
302
303    /** @tentative-return-type */
304    public function setFlags(int $flags): void {}
305
306    /** @tentative-return-type */
307    public function getFlags(): int {}
308
309    /** @tentative-return-type */
310    public function setMaxLineLen(int $maxLength): void {}
311
312    /** @tentative-return-type */
313    public function getMaxLineLen(): int {}
314
315    /** @tentative-return-type */
316    public function hasChildren(): false {}
317
318    /** @tentative-return-type */
319    public function getChildren(): null {}
320
321    /** @tentative-return-type */
322    public function seek(int $line): void {}
323
324    /**
325     * @tentative-return-type
326     * @alias SplFileObject::fgets
327     */
328    public function getCurrentLine(): string {}
329
330    public function __toString(): string {}
331}
332
333class SplTempFileObject extends SplFileObject
334{
335    public function __construct(int $maxMemory = 2 * 1024 * 1024) {}
336}
337