diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16aadb7..89eb165 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,6 @@ jobs: strategy: matrix: include: - - operating-system: 'ubuntu-latest' - php-version: '8.0' - - operating-system: 'ubuntu-latest' php-version: '8.1' @@ -47,7 +44,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: eio-beta, uv-amphp/ext-uv@master, fiber-amphp/ext-fiber@master + extensions: eio-beta, uv-amphp/ext-uv@master - name: Get Composer cache directory id: composer-cache @@ -95,4 +92,3 @@ jobs: - name: Run composer-require-checker run: php composer-require-checker.phar check composer.json --config-file $PWD/composer-require-check.json if: runner.os != 'Windows' && matrix.composer-require-checker-version != 'none' - diff --git a/composer.json b/composer.json index bbd467d..8217d6c 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ } ], "require": { - "php": ">=8", + "php": ">=8.1", "amphp/amp": "^3", "amphp/byte-stream": "^2", "amphp/cache": "^2", diff --git a/psalm.xml b/psalm.xml index 00e053e..e774aea 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,8 +1,7 @@ handle = $handle; $this->path = $path; $this->mode = $mode; + + $this->onClose = new DeferredFuture; } public function __destruct() @@ -31,6 +36,10 @@ public function __destruct() if ($this->handle !== null) { @\fclose($this->handle); } + + if (!$this->onClose->isComplete()) { + $this->onClose->complete(); + } } public function read(?Cancellation $cancellation = null, int $length = self::DEFAULT_READ_LENGTH): ?string @@ -93,6 +102,10 @@ public function close(): void $handle = $this->handle; $this->handle = null; + if (!$this->onClose->isComplete()) { + $this->onClose->complete(); + } + try { \set_error_handler(function ($type, $message) { throw new StreamException("Failed closing file '{$this->path}': {$message}"); @@ -113,6 +126,11 @@ public function isClosed(): bool return $this->handle === null; } + public function onClose(\Closure $onClose): void + { + $this->onClose->getFuture()->finally($onClose); + } + public function truncate(int $size): void { if ($this->handle === null) { diff --git a/src/Driver/EioFile.php b/src/Driver/EioFile.php index fa12b17..bd7446b 100644 --- a/src/Driver/EioFile.php +++ b/src/Driver/EioFile.php @@ -14,7 +14,7 @@ final class EioFile implements File { - private Internal\EioPoll $poll; + private readonly Internal\EioPoll $poll; /** @var resource eio file handle. */ private $fh; @@ -35,12 +35,10 @@ final class EioFile implements File private ?Future $closing = null; + private readonly DeferredFuture $onClose; + /** - * @param Internal\EioPoll $poll * @param resource $fh - * @param string $path - * @param string $mode - * @param int $size */ public function __construct(Internal\EioPoll $poll, $fh, string $path, string $mode, int $size) { @@ -52,6 +50,14 @@ public function __construct(Internal\EioPoll $poll, $fh, string $path, string $m $this->position = ($mode[0] === "a") ? $size : 0; $this->queue = new \SplQueue; + $this->onClose = new DeferredFuture; + } + + public function __destruct() + { + if (!$this->onClose->isComplete()) { + $this->onClose->complete(); + } } public function read(?Cancellation $cancellation = null, int $length = self::DEFAULT_READ_LENGTH): ?string @@ -63,7 +69,7 @@ public function read(?Cancellation $cancellation = null, int $length = self::DEF $this->isActive = true; $remaining = $this->size - $this->position; - $length = $length > $remaining ? $remaining : $length; + $length = \min($length, $remaining); $deferred = new DeferredFuture; $this->poll->listen(); @@ -152,14 +158,13 @@ public function close(): void return; } - $deferred = new DeferredFuture; - $this->closing = $deferred->getFuture(); + $this->closing = $this->onClose->getFuture(); $this->poll->listen(); \eio_close($this->fh, \EIO_PRI_DEFAULT, static function (DeferredFuture $deferred): void { // Ignore errors when closing file, as the handle will become invalid anyway. - $deferred->complete(null); - }, $deferred); + $deferred->complete(); + }, $this->onClose); try { $this->closing->await(); @@ -173,6 +178,11 @@ public function isClosed(): bool return $this->closing !== null; } + public function onClose(\Closure $onClose): void + { + $this->onClose->getFuture()->finally($onClose); + } + public function truncate(int $size): void { if ($this->isActive && $this->queue->isEmpty()) { diff --git a/src/Driver/ParallelFile.php b/src/Driver/ParallelFile.php index f28dcba..40f9534 100644 --- a/src/Driver/ParallelFile.php +++ b/src/Driver/ParallelFile.php @@ -5,6 +5,7 @@ use Amp\ByteStream\ClosedException; use Amp\ByteStream\StreamException; use Amp\Cancellation; +use Amp\DeferredFuture; use Amp\File\File; use Amp\File\Internal; use Amp\File\PendingOperationError; @@ -16,7 +17,7 @@ final class ParallelFile implements File { - private Internal\FileWorker $worker; + private readonly Internal\FileWorker $worker; private ?int $id; @@ -38,13 +39,8 @@ final class ParallelFile implements File private ?Future $closing = null; - /** - * @param Internal\FileWorker $worker - * @param int $id - * @param string $path - * @param int $size - * @param string $mode - */ + private readonly DeferredFuture $onClose; + public function __construct(Internal\FileWorker $worker, int $id, string $path, int $size, string $mode) { $this->worker = $worker; @@ -53,6 +49,8 @@ public function __construct(Internal\FileWorker $worker, int $id, string $path, $this->size = $size; $this->mode = $mode; $this->position = $this->mode[0] === 'a' ? $this->size : 0; + + $this->onClose = new DeferredFuture; } public function __destruct() @@ -62,6 +60,10 @@ public function __destruct() $worker = $this->worker; EventLoop::queue(static fn () => $worker->execute(new Internal\FileTask('fclose', [], $id))); } + + if (!$this->onClose->isComplete()) { + $this->onClose->complete(); + } } public function close(): void @@ -83,7 +85,11 @@ public function close(): void $this->worker->execute(new Internal\FileTask('fclose', [], $id)); }); - $this->closing->await(); + try { + $this->closing->await(); + } finally { + $this->onClose->complete(); + } } public function isClosed(): bool @@ -91,6 +97,11 @@ public function isClosed(): bool return $this->closing !== null; } + public function onClose(\Closure $onClose): void + { + $this->onClose->getFuture()->finally($onClose); + } + public function truncate(int $size): void { if ($this->id === null) { diff --git a/src/Driver/ParallelFilesystemDriver.php b/src/Driver/ParallelFilesystemDriver.php index 07a8d90..d84ec86 100644 --- a/src/Driver/ParallelFilesystemDriver.php +++ b/src/Driver/ParallelFilesystemDriver.php @@ -30,7 +30,6 @@ final class ParallelFilesystemDriver implements FilesystemDriver private Future $pendingWorker; /** - * @param WorkerPool|null $pool * @param int $workerLimit Maximum number of workers to use from the pool for open files. */ public function __construct(WorkerPool $pool = null, int $workerLimit = self::DEFAULT_WORKER_LIMIT) diff --git a/src/Driver/StatusCachingFile.php b/src/Driver/StatusCachingFile.php index e1da4d0..b147887 100644 --- a/src/Driver/StatusCachingFile.php +++ b/src/Driver/StatusCachingFile.php @@ -7,18 +7,17 @@ final class StatusCachingFile implements File { - private File $file; + private readonly File $file; - /** @var callable */ - private $invalidateCallback; + private readonly \Closure $invalidateCallback; /** * @param File $file Decorated instance. - * @param callable $invalidateCallback Invalidation callback. + * @param \Closure $invalidateCallback Invalidation callback. * * @internal */ - public function __construct(File $file, callable $invalidateCallback) + public function __construct(File $file, \Closure $invalidateCallback) { $this->file = $file; $this->invalidateCallback = $invalidateCallback; @@ -57,6 +56,11 @@ public function isClosed(): bool return $this->file->isClosed(); } + public function onClose(\Closure $onClose): void + { + $this->file->onClose($onClose); + } + public function seek(int $position, int $whence = self::SEEK_SET): int { return $this->file->seek($position, $whence); diff --git a/src/Driver/StatusCachingFilesystemDriver.php b/src/Driver/StatusCachingFilesystemDriver.php index cea2761..82bae8d 100644 --- a/src/Driver/StatusCachingFilesystemDriver.php +++ b/src/Driver/StatusCachingFilesystemDriver.php @@ -8,10 +8,8 @@ final class StatusCachingFilesystemDriver implements FilesystemDriver { - /** @var FilesystemDriver */ private FilesystemDriver $driver; - /** @var Cache */ private Cache $statusCache; public function __construct(FilesystemDriver $driver) diff --git a/src/Driver/UvFile.php b/src/Driver/UvFile.php index 1c1e646..2a2b402 100644 --- a/src/Driver/UvFile.php +++ b/src/Driver/UvFile.php @@ -15,7 +15,7 @@ final class UvFile implements File { - private Internal\UvPoll $poll; + private readonly Internal\UvPoll $poll; /** @var \UVLoop|resource */ private $eventLoopHandle; @@ -42,13 +42,11 @@ final class UvFile implements File /** @var bool True if ext-uv version is < 0.3.0. */ private bool $priorVersion; + private readonly DeferredFuture $onClose; + /** - * @param UvLoopDriver $driver * @param Internal\UvPoll $poll Poll for keeping the loop active. * @param resource $fh File handle. - * @param string $path - * @param string $mode - * @param int $size */ public function __construct( UvLoopDriver $driver, @@ -69,10 +67,18 @@ public function __construct( $this->position = ($mode[0] === "a") ? $size : 0; $this->queue = new \SplQueue; + $this->onClose = new DeferredFuture; $this->priorVersion = \version_compare(\phpversion('uv'), '0.3.0', '<'); } + public function __destruct() + { + if (!$this->onClose->isComplete()) { + $this->onClose->complete(); + } + } + public function read(?Cancellation $cancellation = null, int $length = self::DEFAULT_READ_LENGTH): ?string { if ($this->isActive) { @@ -242,16 +248,17 @@ public function close(): void return; } - $deferred = new DeferredFuture; + $deferred = $this->onClose; + $this->closing = $deferred->getFuture(); $this->poll->listen(); \uv_fs_close($this->eventLoopHandle, $this->fh, static function () use ($deferred): void { // Ignore errors when closing file, as the handle will become invalid anyway. - $deferred->complete(null); + $deferred->complete(); }); try { - $deferred->getFuture()->await(); + $this->closing->await(); } finally { $this->poll->done(); } @@ -262,6 +269,11 @@ public function isClosed(): bool return $this->closing !== null; } + public function onClose(\Closure $onClose): void + { + $this->onClose->getFuture()->finally($onClose); + } + private function push(string $data): Future { $length = \strlen($data); diff --git a/src/Driver/UvFilesystemDriver.php b/src/Driver/UvFilesystemDriver.php index be9f61d..9f69bff 100644 --- a/src/Driver/UvFilesystemDriver.php +++ b/src/Driver/UvFilesystemDriver.php @@ -22,16 +22,15 @@ public static function isSupported(EventLoopDriver $driver): bool return $driver instanceof UvLoopDriver; } - private UvLoopDriver $driver; + private readonly UvLoopDriver $driver; /** @var \UVLoop|resource Loop resource of type uv_loop or instance of \UVLoop. */ private $eventLoopHandle; - /** @var Internal\UvPoll */ - private Internal\UvPoll $poll; + private readonly Internal\UvPoll $poll; /** @var bool True if ext-uv version is < 0.3.0. */ - private bool $priorVersion; + private readonly bool $priorVersion; public function __construct(UvLoopDriver $driver) { diff --git a/src/File.php b/src/File.php index a419859..49e3d6d 100644 --- a/src/File.php +++ b/src/File.php @@ -17,10 +17,7 @@ interface File extends ReadableStream, WritableStream /** * Read $length bytes from the open file handle. * - * @param Cancellation|null $cancellation - * @param int $length * - * @return string|null */ public function read(?Cancellation $cancellation = null, int $length = self::DEFAULT_READ_LENGTH): ?string; @@ -33,8 +30,6 @@ public function read(?Cancellation $cancellation = null, int $length = self::DEF * SEEK_CUR - Set position to current location plus offset. * SEEK_END - Set position to end-of-file plus offset. * - * @param int $position - * @param int $whence * * @return int New offset position. */ @@ -43,14 +38,12 @@ public function seek(int $position, int $whence = self::SEEK_SET): int; /** * Return the current internal offset position of the file handle. * - * @return int */ public function tell(): int; /** * Test for being at the end of the stream (a.k.a. "end-of-file"). * - * @return bool */ public function eof(): bool; @@ -62,14 +55,12 @@ public function isSeekable(): bool; /** * Retrieve the path used when opening the file handle. * - * @return string */ public function getPath(): string; /** * Retrieve the mode used when opening the file handle. * - * @return string */ public function getMode(): string; diff --git a/src/Filesystem.php b/src/Filesystem.php index e33ef3d..44b53b3 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -14,11 +14,6 @@ public function __construct(FilesystemDriver $driver) /** * Open a handle for the specified path. * - * @param string $path - * @param string $mode - * - * @return File - * * @throws FilesystemException */ public function openFile(string $path, string $mode): File @@ -32,8 +27,6 @@ public function openFile(string $path, string $mode): File * If the requested path does not exist the resulting Promise will resolve to NULL. * * @param string $path File system path. - * - * @return array|null */ public function getStatus(string $path): ?array { @@ -46,8 +39,6 @@ public function getStatus(string $path): ?array * If the requested path does not exist the resulting Promise will resolve to NULL. * * @param string $path File system path. - * - * @return array|null */ public function getLinkStatus(string $path): ?array { @@ -61,8 +52,6 @@ public function getLinkStatus(string $path): ?array * indicating the existence of the specified path. * * @param string $path File system path. - * - * @return bool */ public function exists(string $path): bool { @@ -101,8 +90,6 @@ public function getSize(string $path): int * Does the specified path exist and is it a directory? * * @param string $path File system path. - * - * @return bool */ public function isDirectory(string $path): bool { @@ -118,8 +105,6 @@ public function isDirectory(string $path): bool * Does the specified path exist and is it a file? * * @param string $path File system path. - * - * @return bool */ public function isFile(string $path): bool { @@ -138,8 +123,6 @@ public function isFile(string $path): bool * to FALSE and will not reject with an error. * * @param string $path File system path. - * - * @return bool */ public function isSymlink(string $path): bool { @@ -156,8 +139,6 @@ public function isSymlink(string $path): bool * * @param string $path File system path. * - * @return int - * * @throws FilesystemException If the path does not exist. */ public function getModificationTime(string $path): int @@ -175,8 +156,6 @@ public function getModificationTime(string $path): int * * @param string $path File system path. * - * @return int - * * @throws FilesystemException If the path does not exist. */ public function getAccessTime(string $path): int @@ -194,8 +173,6 @@ public function getAccessTime(string $path): int * * @param string $path File system path. * - * @return int - * * @throws FilesystemException If the path does not exist. */ public function getCreationTime(string $path): int @@ -211,9 +188,6 @@ public function getCreationTime(string $path): int /** * Create a symlink $link pointing to the file/directory located at $original. * - * @param string $original - * @param string $link - * * @throws FilesystemException If the operation fails. */ public function createSymlink(string $original, string $link): void @@ -223,10 +197,6 @@ public function createSymlink(string $original, string $link): void /** * Create a hard link $link pointing to the file/directory located at $target. - * - * @param string $target - * @param string $link - * @fails \Amp\Files\FilesystemException If the operation fails. */ public function createHardlink(string $target, string $link): void { @@ -236,11 +206,6 @@ public function createHardlink(string $target, string $link): void /** * Resolve the symlink at $path. * - * @param string $path - * @fails \Amp\Files\FilesystemException If the operation fails. - * - * @return string - * * @throws FilesystemException */ public function resolveSymlink(string $path): string @@ -251,8 +216,6 @@ public function resolveSymlink(string $path): string /** * Move / rename a file or directory. * - * @param string $from - * @param string $to * * @throws FilesystemException If the operation fails. */ @@ -264,8 +227,6 @@ public function move(string $from, string $to): void /** * Delete a file. * - * @param string $path - * * @throws FilesystemException If the operation fails. */ public function deleteFile(string $path): void @@ -276,9 +237,6 @@ public function deleteFile(string $path): void /** * Create a directory. * - * @param string $path - * @param int $mode - * * @throws FilesystemException If the operation fails. */ public function createDirectory(string $path, int $mode = 0777): void @@ -289,9 +247,6 @@ public function createDirectory(string $path, int $mode = 0777): void /** * Create a directory recursively. * - * @param string $path - * @param int $mode - * * @throws FilesystemException If the operation fails. */ public function createDirectoryRecursively(string $path, int $mode = 0777): void @@ -302,8 +257,6 @@ public function createDirectoryRecursively(string $path, int $mode = 0777): void /** * Delete a directory. * - * @param string $path - * * @throws FilesystemException If the operation fails. */ public function deleteDirectory(string $path): void @@ -316,8 +269,6 @@ public function deleteDirectory(string $path): void * * Dot entries are not included in the resulting array (i.e. "." and ".."). * - * @param string $path - * * @return list * * @throws FilesystemException If the operation fails. @@ -329,10 +280,6 @@ public function listFiles(string $path): array /** * Change permissions of a file or directory. - * - * @param string $path - * @param int $mode - * @fails \Amp\Files\FilesystemException If the operation fails. */ public function changePermissions(string $path, int $mode): void { @@ -342,10 +289,8 @@ public function changePermissions(string $path, int $mode): void /** * Change ownership of a file or directory. * - * @param string $path * @param int|null $uid null to ignore * @param int|null $gid null to ignore - * @fails \Amp\Files\FilesystemException If the operation fails. */ public function changeOwner(string $path, ?int $uid, ?int $gid = null): void { @@ -357,10 +302,8 @@ public function changeOwner(string $path, ?int $uid, ?int $gid = null): void * * If the file does not exist it will be created automatically. * - * @param string $path * @param int|null $modificationTime The touch time. If $time is not supplied, the current system time is used. * @param int|null $accessTime The access time. If not supplied, the modification time is used. - * @fails \Amp\Files\FilesystemException If the operation fails. */ public function touch(string $path, ?int $modificationTime = null, ?int $accessTime = null): void { diff --git a/src/FilesystemDriver.php b/src/FilesystemDriver.php index dd9cec5..da522b3 100644 --- a/src/FilesystemDriver.php +++ b/src/FilesystemDriver.php @@ -7,11 +7,6 @@ interface FilesystemDriver /** * Open a handle for the specified path. * - * @param string $path - * @param string $mode - * - * @return File - * * @throws FilesystemException */ public function openFile(string $path, string $mode): File; @@ -22,8 +17,6 @@ public function openFile(string $path, string $mode): File; * If the requested path does not exist, it returns {@code null}. * * @param string $path The file system path to stat. - * - * @return array|null */ public function getStatus(string $path): ?array; @@ -41,9 +34,6 @@ public function getLinkStatus(string $path): ?array; /** * Create a symlink $link pointing to the file/directory located at $target. * - * @param string $target - * @param string $link - * * @throws FilesystemException */ public function createSymlink(string $target, string $link): void; @@ -51,9 +41,6 @@ public function createSymlink(string $target, string $link): void; /** * Create a hard link $link pointing to the file/directory located at $target. * - * @param string $target - * @param string $link - * * @throws FilesystemException */ public function createHardlink(string $target, string $link): void; @@ -61,8 +48,6 @@ public function createHardlink(string $target, string $link): void; /** * Resolve the symlink at $path. * - * @param string $target - * * @throws FilesystemException */ public function resolveSymlink(string $target): string; @@ -70,9 +55,6 @@ public function resolveSymlink(string $target): string; /** * Move / rename a file or directory. * - * @param string $from - * @param string $to - * * @throws FilesystemException */ public function move(string $from, string $to): void; @@ -80,8 +62,6 @@ public function move(string $from, string $to): void; /** * Delete a file. * - * @param string $path - * * @throws FilesystemException */ public function deleteFile(string $path): void; @@ -89,9 +69,6 @@ public function deleteFile(string $path): void; /** * Create a directory. * - * @param string $path - * @param int $mode - * * @throws FilesystemException */ public function createDirectory(string $path, int $mode = 0777): void; @@ -99,9 +76,6 @@ public function createDirectory(string $path, int $mode = 0777): void; /** * Create a directory recursively. * - * @param string $path - * @param int $mode - * * @throws FilesystemException If the operation fails. */ public function createDirectoryRecursively(string $path, int $mode = 0777): void; @@ -109,8 +83,6 @@ public function createDirectoryRecursively(string $path, int $mode = 0777): void /** * Delete a directory. * - * @param string $path - * * @throws FilesystemException If the operation fails. */ public function deleteDirectory(string $path): void; @@ -120,8 +92,6 @@ public function deleteDirectory(string $path): void; * * Dot entries are not included in the resulting array (i.e. "." and ".."). * - * @param string $path - * * @return list * * @throws FilesystemException If the operation fails. @@ -131,9 +101,6 @@ public function listFiles(string $path): array; /** * chmod a file or directory. * - * @param string $path - * @param int $mode - * * @throws FilesystemException If the operation fails. */ public function changePermissions(string $path, int $mode): void; @@ -141,10 +108,6 @@ public function changePermissions(string $path, int $mode): void; /** * chown a file or directory. * - * @param string $path - * @param int|null $uid - * @param int|null $gid - * * @throws FilesystemException If the operation fails. */ public function changeOwner(string $path, ?int $uid, ?int $gid): void; @@ -154,7 +117,6 @@ public function changeOwner(string $path, ?int $uid, ?int $gid): void; * * If the file does not exist it will be created automatically. * - * @param string $path * @param int|null $modificationTime The touch time. If $time is not supplied, the current system time is used. * @param int|null $accessTime The access time. If $atime is not supplied, value passed to the $time parameter is * used. diff --git a/src/Internal/Cache.php b/src/Internal/Cache.php index 62b09d9..adc4ed7 100644 --- a/src/Internal/Cache.php +++ b/src/Internal/Cache.php @@ -28,7 +28,7 @@ public function __construct(int $gcInterval = 1000, ?int $maxSize = null) public array $cache = []; /** @var int[] */ public array $cacheTimeouts = []; - /** @var bool */ + public bool $isSortNeeded = false; public function collectGarbage(): void diff --git a/src/Internal/FileTask.php b/src/Internal/FileTask.php index cb5df0c..a54bf42 100644 --- a/src/Internal/FileTask.php +++ b/src/Internal/FileTask.php @@ -31,8 +31,6 @@ private static function makeId(int $id): string private ?int $id; /** - * @param string $operation - * @param array $args * @param int|null $id File ID. * * @throws \Error diff --git a/src/Internal/FileWorker.php b/src/Internal/FileWorker.php index 343eed8..d8a1166 100644 --- a/src/Internal/FileWorker.php +++ b/src/Internal/FileWorker.php @@ -14,7 +14,6 @@ final class FileWorker private Worker $worker; /** - * @param Worker $worker * @param \Closure(Worker):void $push Closure to push the worker back into the queue. */ public function __construct(Worker $worker, \Closure $push) diff --git a/src/functions.php b/src/functions.php index 8e1dba1..945405e 100644 --- a/src/functions.php +++ b/src/functions.php @@ -14,7 +14,6 @@ * * @param FilesystemDriver|null $driver Use the specified object as the application-wide filesystem instance. * - * @return Filesystem */ function filesystem(?FilesystemDriver $driver = null): Filesystem { @@ -50,8 +49,6 @@ function filesystem(?FilesystemDriver $driver = null): Filesystem /** * Create a new filesystem driver best-suited for the current environment. - * - * @return FilesystemDriver */ function createDefaultDriver(): FilesystemDriver { @@ -76,11 +73,6 @@ function createDefaultDriver(): FilesystemDriver /** * Open a handle for the specified path. * - * @param string $path - * @param string $mode - * - * @return File - * * @throws FilesystemException */ function openFile(string $path, string $mode): File @@ -94,8 +86,6 @@ function openFile(string $path, string $mode): File * If the requested path does not exist the function will return NULL. * * @param string $path File system path. - * - * @return array|null */ function getStatus(string $path): ?array { @@ -108,8 +98,6 @@ function getStatus(string $path): ?array * If the requested path does not exist the function will return NULL. * * @param string $path File system path. - * - * @return array|null */ function getLinkStatus(string $path): ?array { @@ -123,8 +111,6 @@ function getLinkStatus(string $path): ?array * indicating the existence of the specified path. * * @param string $path File system path. - * - * @return bool */ function exists(string $path): bool { @@ -135,9 +121,6 @@ function exists(string $path): bool * Retrieve the size in bytes of the file at the specified path. * * @param string $path File system path. - * @fails \Amp\Files\FilesystemException If the path does not exist or is not a file. - * - * @return int */ function getSize(string $path): int { @@ -148,8 +131,6 @@ function getSize(string $path): int * Does the specified path exist and is it a directory? * * @param string $path File system path. - * - * @return bool */ function isDirectory(string $path): bool { @@ -160,8 +141,6 @@ function isDirectory(string $path): bool * Does the specified path exist and is it a file? * * @param string $path File system path. - * - * @return bool */ function isFile(string $path): bool { @@ -172,8 +151,6 @@ function isFile(string $path): bool * Does the specified path exist and is it a symlink? * * @param string $path File system path. - * - * @return bool */ function isSymlink(string $path): bool { @@ -184,9 +161,6 @@ function isSymlink(string $path): bool * Retrieve the path's last modification time as a unix timestamp. * * @param string $path File system path. - * @fails \Amp\Files\FilesystemException If the path does not exist. - * - * @return int */ function getModificationTime(string $path): int { @@ -197,9 +171,6 @@ function getModificationTime(string $path): int * Retrieve the path's last access time as a unix timestamp. * * @param string $path File system path. - * @fails \Amp\Files\FilesystemException If the path does not exist. - * - * @return int */ function getAccessTime(string $path): int { @@ -210,7 +181,6 @@ function getAccessTime(string $path): int * Retrieve the path's creation time as a unix timestamp. * * @param string $path File system path. - * @fails \Amp\Files\FilesystemException If the path does not exist. */ function getCreationTime(string $path): int { @@ -219,10 +189,6 @@ function getCreationTime(string $path): int /** * Create a symlink $link pointing to the file/directory located at $original. - * - * @param string $original - * @param string $link - * @fails \Amp\Files\FilesystemException If the operation fails. */ function createSymlink(string $original, string $link): void { @@ -231,10 +197,6 @@ function createSymlink(string $original, string $link): void /** * Create a hard link $link pointing to the file/directory located at $target. - * - * @param string $target - * @param string $link - * @fails \Amp\Files\FilesystemException If the operation fails. */ function createHardlink(string $target, string $link): void { @@ -243,11 +205,6 @@ function createHardlink(string $target, string $link): void /** * Resolve the symlink at $path. - * - * @param string $path - * @fails \Amp\Files\FilesystemException If the operation fails. - * - * @return string */ function resolveSymlink(string $path): string { @@ -256,10 +213,6 @@ function resolveSymlink(string $path): string /** * Move / rename a file or directory. - * - * @param string $from - * @param string $to - * @fails \Amp\Files\FilesystemException If the operation fails. */ function move(string $from, string $to): void { @@ -268,9 +221,6 @@ function move(string $from, string $to): void /** * Delete a file. - * - * @param string $path - * @fails \Amp\Files\FilesystemException If the operation fails. */ function deleteFile(string $path): void { @@ -279,10 +229,6 @@ function deleteFile(string $path): void /** * Create a directory. - * - * @param string $path - * @param int $mode - * @fails \Amp\Files\FilesystemException If the operation fails. */ function createDirectory(string $path, int $mode = 0777): void { @@ -291,10 +237,6 @@ function createDirectory(string $path, int $mode = 0777): void /** * Create a directory recursively. - * - * @param string $path - * @param int $mode - * @fails \Amp\Files\FilesystemException If the operation fails. */ function createDirectoryRecursively(string $path, int $mode = 0777): void { @@ -303,9 +245,6 @@ function createDirectoryRecursively(string $path, int $mode = 0777): void /** * Delete a directory. - * - * @param string $path - * @fails \Amp\Files\FilesystemException If the operation fails. */ function deleteDirectory(string $path): void { @@ -317,9 +256,7 @@ function deleteDirectory(string $path): void * * Dot entries are not included in the resulting array (i.e. "." and ".."). * - * @param string $path - * - * @returnlist + * @return list */ function listFiles(string $path): array { @@ -328,10 +265,6 @@ function listFiles(string $path): array /** * Change permissions of a file or directory. - * - * @param string $path - * @param int $mode - * @fails \Amp\Files\FilesystemException If the operation fails. */ function changePermissions(string $path, int $mode): void { @@ -341,10 +274,8 @@ function changePermissions(string $path, int $mode): void /** * Change ownership of a file or directory. * - * @param string $path * @param int|null $uid null to ignore * @param int|null $gid null to ignore - * @fails \Amp\Files\FilesystemException If the operation fails. */ function changeOwner(string $path, ?int $uid, ?int $gid = null): void { @@ -356,10 +287,8 @@ function changeOwner(string $path, ?int $uid, ?int $gid = null): void * * If the file does not exist it will be created automatically. * - * @param string $path * @param int|null $modificationTime The touch time. If $time is not supplied, the current system time is used. * @param int|null $accessTime The access time. If not supplied, the modification time is used. - * @fails \Amp\Files\FilesystemException If the operation fails. */ function touch(string $path, ?int $modificationTime = null, ?int $accessTime = null): void { @@ -370,8 +299,6 @@ function touch(string $path, ?int $modificationTime = null, ?int $accessTime = n * Buffer the specified file's contents. * * @param string $path The file path from which to buffer contents. - * - * @return string */ function read(string $path): string { diff --git a/test/Driver/UvFilesystemDriverTest.php b/test/Driver/UvFilesystemDriverTest.php index 063c758..8227476 100644 --- a/test/Driver/UvFilesystemDriverTest.php +++ b/test/Driver/UvFilesystemDriverTest.php @@ -13,7 +13,6 @@ class UvFilesystemDriverTest extends FilesystemDriverTest /** * @dataProvider symlinkPathProvider * - * @param \Closure $linkResolver */ public function testResolveSymlinkError(\Closure $linkResolver): void { diff --git a/test/FilesystemDriverTest.php b/test/FilesystemDriverTest.php index bb56d1c..a403f2b 100644 --- a/test/FilesystemDriverTest.php +++ b/test/FilesystemDriverTest.php @@ -106,7 +106,6 @@ static function () { /** * @dataProvider symlinkPathProvider * - * @param \Closure $linkResolver */ public function testResolveSymlinkError(\Closure $linkResolver): void { @@ -567,11 +566,6 @@ function (string $key): bool { $this->assertSame($filter($expected), $filter($actual)); } - /** - * @param array $stat - * - * @return string - */ private function getPermissionsFromStatus(array $stat): string { return \substr(\decoct($stat["mode"]), 1);