Skip to content

Commit

Permalink
Refactor StreamWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Aug 13, 2023
1 parent 22cbf86 commit 25f2b22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Helper/StreamWrapper/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/Helper/StreamWrapper/StreamWrapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 25f2b22

Please sign in to comment.