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