1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/spl/spl_directory.stub.php
Calvin Buckley 76791e90b9 Use win32 glob implementation on all platforms (#18164)
* Move glob to main/ from win32/

In preparation to make the Win32 reimplementation the standard
cross-platform one. Currently, it doesn't do that and just passes
through the original glob implementation. We could consider also having
an option to use the standard glob for systems that have a sufficient
one.

* Enable building with win32 glob on non-windows

Kind of broken. We're namespacing the function and struct, but not yet
the GLOB_* defines. There are a lot of places callers check if i.e.
NOMATCH is defined that would likely become redundant.

Currently it also has php_glob and #defines glob php_glob (etc.) - I
suspect doing the opposite and changing the callers would make more
sense, just doing MVP to geet it to build (even if it fails tests).

* Massive first pass at conversion to internal glob

Have not tested yet. the big things are:

- Should be invisible to userland PHP code.
- A lot of :%s/GLOB_/PHP_GLOB_/g; the diff can be noisy as a result,
  especially in comments.
- Prefixes everything with PHP_ to avoid conflicts with system glob in
  case it gets included transitively.
- A lot of weird shared definitions that were sprawled out to other
  headers are now included in php_glob.h.
- A lot of (but not yet all cases) of HAVE_GLOB are removed, since we
  can always fall back to php_glob.
- Using the system glob is not wired up yet; it'll need more shim
  ifdefs for each flag type than just glob_t/glob/globfree defs.

* Fix inclusion of GLOB_ONLYDIR

This is a GNU extension, but we don't need to implement it, as the GNU
implementation is flawed enough that callers have to manually filter it
anyways; just provide a stub definition for the constant.

We could consideer implementing this properly later. For now, fixes the
basic glob constant tests.

* Remove HAVE_GLOBs

We now always have a glob implementation that works. HAVE_GLOB should
only be used to check if we have a system implementation, for if we
decide to wrap the system implementation instead.

* We don't need to care about being POSIXly correct for internal glob

* Check for reallocarray

Ideally temporary until GH-17433.

* Forgot to move this file from win32/ to main/

* Check for issetugid (BSD function)

* Allow using the system glob with --enable-system-glob

* Style fix after removing ifdef

* Remove empty case for system glob
2025-05-20 16:20:59 -03:00

335 lines
10 KiB
PHP

<?php
/** @generate-class-entries */
/** @not-serializable */
class SplFileInfo implements Stringable
{
public function __construct(string $filename) {}
/** @tentative-return-type */
public function getPath(): string {}
/** @tentative-return-type */
public function getFilename(): string {}
/** @tentative-return-type */
public function getExtension(): string {}
/** @tentative-return-type */
public function getBasename(string $suffix = ""): string {}
/** @tentative-return-type */
public function getPathname(): string {}
/** @tentative-return-type */
public function getPerms(): int|false {}
/** @tentative-return-type */
public function getInode(): int|false {}
/** @tentative-return-type */
public function getSize(): int|false {}
/** @tentative-return-type */
public function getOwner(): int|false {}
/** @tentative-return-type */
public function getGroup(): int|false {}
/** @tentative-return-type */
public function getATime(): int|false {}
/** @tentative-return-type */
public function getMTime(): int|false {}
/** @tentative-return-type */
public function getCTime(): int|false {}
/** @tentative-return-type */
public function getType(): string|false {}
/** @tentative-return-type */
public function isWritable(): bool {}
/** @tentative-return-type */
public function isReadable(): bool {}
/** @tentative-return-type */
public function isExecutable(): bool {}
/** @tentative-return-type */
public function isFile(): bool {}
/** @tentative-return-type */
public function isDir(): bool {}
/** @tentative-return-type */
public function isLink(): bool {}
/** @tentative-return-type */
public function getLinkTarget(): string|false {}
/** @tentative-return-type */
public function getRealPath(): string|false {}
/** @tentative-return-type */
public function getFileInfo(?string $class = null): SplFileInfo {}
/** @tentative-return-type */
public function getPathInfo(?string $class = null): ?SplFileInfo {}
/**
* @param resource|null $context
* @tentative-return-type
*/
public function openFile(string $mode = "r", bool $useIncludePath = false, $context = null): SplFileObject {}
/** @tentative-return-type */
public function setFileClass(string $class = SplFileObject::class): void {}
/** @tentative-return-type */
public function setInfoClass(string $class = SplFileInfo::class): void {}
/** @implementation-alias SplFileInfo::getPathname */
public function __toString(): string {}
/** @tentative-return-type */
public function __debugInfo(): array {}
#[\Deprecated(since: '8.2')]
final public function _bad_state_ex(): void {}
}
class DirectoryIterator extends SplFileInfo implements SeekableIterator
{
public function __construct(string $directory) {}
/** @tentative-return-type */
public function getFilename(): string {}
/** @tentative-return-type */
public function getExtension(): string {}
/** @tentative-return-type */
public function getBasename(string $suffix = ""): string {}
/** @tentative-return-type */
public function isDot(): bool {}
/** @tentative-return-type */
public function rewind(): void {}
/** @tentative-return-type */
public function valid(): bool {}
/**
* @tentative-return-type
* @return int
*/
public function key(): mixed {} // TODO change return type to string
/**
* @tentative-return-type
* @return DirectoryIterator
*/
public function current(): mixed {} // TODO narrow return type
/** @tentative-return-type */
public function next(): void {}
/** @tentative-return-type */
public function seek(int $offset): void {}
/** @implementation-alias DirectoryIterator::getFilename */
public function __toString(): string {}
}
class FilesystemIterator extends DirectoryIterator
{
/** @cvalue SPL_FILE_DIR_CURRENT_MODE_MASK */
public const int CURRENT_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_PATHNAME */
public const int CURRENT_AS_PATHNAME = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_FILEINFO */
public const int CURRENT_AS_FILEINFO = UNKNOWN;
/** @cvalue SPL_FILE_DIR_CURRENT_AS_SELF */
public const int CURRENT_AS_SELF = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_MODE_MASK */
public const int KEY_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_AS_PATHNAME */
public const int KEY_AS_PATHNAME = UNKNOWN;
/** @cvalue SPL_FILE_DIR_FOLLOW_SYMLINKS */
public const int FOLLOW_SYMLINKS = UNKNOWN;
/** @cvalue SPL_FILE_DIR_KEY_AS_FILENAME */
public const int KEY_AS_FILENAME = UNKNOWN;
/** @cvalue SPL_FILE_NEW_CURRENT_AND_KEY */
public const int NEW_CURRENT_AND_KEY = UNKNOWN;
/** @cvalue SPL_FILE_DIR_OTHERS_MASK */
public const int OTHER_MODE_MASK = UNKNOWN;
/** @cvalue SPL_FILE_DIR_SKIPDOTS */
public const int SKIP_DOTS = UNKNOWN;
/** @cvalue SPL_FILE_DIR_UNIXPATHS */
public const int UNIX_PATHS = UNKNOWN;
public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS) {}
/** @tentative-return-type */
public function rewind(): void {}
/** @tentative-return-type */
public function key(): string {}
/** @tentative-return-type */
public function current(): string|SplFileInfo|FilesystemIterator {}
/** @tentative-return-type */
public function getFlags(): int {}
/** @tentative-return-type */
public function setFlags(int $flags): void {}
}
class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
{
public function __construct(string $directory, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
/** @tentative-return-type */
public function hasChildren(bool $allowLinks = false): bool {}
/** @tentative-return-type */
public function getChildren(): RecursiveDirectoryIterator {}
/** @tentative-return-type */
public function getSubPath(): string {}
/** @tentative-return-type */
public function getSubPathname(): string {}
}
class GlobIterator extends FilesystemIterator implements Countable
{
public function __construct(string $pattern, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO) {}
/** @tentative-return-type */
public function count(): int {}
}
class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
{
/** @cvalue SPL_FILE_OBJECT_DROP_NEW_LINE */
public const int DROP_NEW_LINE = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_READ_AHEAD */
public const int READ_AHEAD = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_SKIP_EMPTY */
public const int SKIP_EMPTY = UNKNOWN;
/** @cvalue SPL_FILE_OBJECT_READ_CSV */
public const int READ_CSV = UNKNOWN;
/** @param resource|null $context */
public function __construct(string $filename, string $mode = "r", bool $useIncludePath = false, $context = null) {}
/** @tentative-return-type */
public function rewind(): void {}
/** @tentative-return-type */
public function eof(): bool {}
/** @tentative-return-type */
public function valid(): bool {}
/** @tentative-return-type */
public function fgets(): string {}
/** @tentative-return-type */
public function fread(int $length): string|false {}
/** @tentative-return-type */
public function fgetcsv(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false {}
/** @tentative-return-type */
public function fputcsv(array $fields, string $separator = ",", string $enclosure = "\"", string $escape = "\\", string $eol = "\n"): int|false {}
/** @tentative-return-type */
public function setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): void {}
/** @tentative-return-type */
public function getCsvControl(): array {}
/**
* @param int $wouldBlock
* @tentative-return-type
*/
public function flock(int $operation, &$wouldBlock = null): bool {}
/** @tentative-return-type */
public function fflush(): bool {}
/** @tentative-return-type */
public function ftell(): int|false {}
/** @tentative-return-type */
public function fseek(int $offset, int $whence = SEEK_SET): int {}
/** @tentative-return-type */
public function fgetc(): string|false {}
/** @tentative-return-type */
public function fpassthru(): int {}
/** @tentative-return-type */
public function fscanf(string $format, mixed &...$vars): array|int|null {}
/** @tentative-return-type */
public function fwrite(string $data, ?int $length = null): int|false {}
/** @tentative-return-type */
public function fstat(): array {}
/** @tentative-return-type */
public function ftruncate(int $size): bool {}
/** @tentative-return-type */
public function current(): string|array|false {}
/** @tentative-return-type */
public function key(): int {}
/** @tentative-return-type */
public function next(): void {}
/** @tentative-return-type */
public function setFlags(int $flags): void {}
/** @tentative-return-type */
public function getFlags(): int {}
/** @tentative-return-type */
public function setMaxLineLen(int $maxLength): void {}
/** @tentative-return-type */
public function getMaxLineLen(): int {}
/** @tentative-return-type */
public function hasChildren(): false {}
/** @tentative-return-type */
public function getChildren(): null {}
/** @tentative-return-type */
public function seek(int $line): void {}
/**
* @tentative-return-type
* @alias SplFileObject::fgets
*/
public function getCurrentLine(): string {}
public function __toString(): string {}
}
class SplTempFileObject extends SplFileObject
{
public function __construct(int $maxMemory = 2 * 1024 * 1024) {}
}