From 25f2b2254690d1a03199812669fd83dacce691e2 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 13 Aug 2023 23:33:16 +0300 Subject: [PATCH] Refactor `StreamWrapper` --- src/Helper/StreamWrapper/StreamWrapper.php | 15 ++++++--------- .../StreamWrapper/StreamWrapperInterface.php | 3 +++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Helper/StreamWrapper/StreamWrapper.php b/src/Helper/StreamWrapper/StreamWrapper.php index dff89c0d..d3e2a945 100644 --- a/src/Helper/StreamWrapper/StreamWrapper.php +++ b/src/Helper/StreamWrapper/StreamWrapper.php @@ -25,9 +25,9 @@ final class StreamWrapper implements StreamWrapperInterface public ?string $filename = null; /** - * @var resource|null + * @var resource|false */ - public $stream = null; + public $stream = false; public function dir_closedir(): bool { @@ -49,12 +49,7 @@ public function dir_readdir(): false|string public function dir_rewinddir(): bool { - if (!is_resource($this->stream)) { - return false; - } - rewinddir($this->stream); - /** @noinspection PhpConditionAlreadyCheckedInspection */ return is_resource($this->stream); } @@ -76,7 +71,9 @@ public function rmdir(string $path, int $options): bool public function stream_cast(int $castAs) { - //???? + // ???? + + return false; } public function stream_eof(): bool @@ -183,7 +180,7 @@ public function stream_close(): void * @psalm-suppress InvalidPropertyAssignmentValue */ fclose($this->stream); - $this->stream = null; + $this->stream = false; } public function stream_lock(int $operation): bool diff --git a/src/Helper/StreamWrapper/StreamWrapperInterface.php b/src/Helper/StreamWrapper/StreamWrapperInterface.php index 76443a70..3aba08d0 100644 --- a/src/Helper/StreamWrapper/StreamWrapperInterface.php +++ b/src/Helper/StreamWrapper/StreamWrapperInterface.php @@ -23,6 +23,9 @@ public function stream_eof(): bool; public function stream_seek(int $offset, int $whence = SEEK_SET): bool; + /** + * @return resource|false + */ public function stream_cast(int $castAs); public function stream_stat(): array|false;