aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Stream
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-30 07:32:58 +0900
committernsfisis <nsfisis@gmail.com>2025-07-30 07:32:58 +0900
commit7f3246e4582a488327f2a9da01111db1a4a32b91 (patch)
treec37f919e41949d1b482aaae4bedbdd2f65b5baef /src/Stream
parent6f18d4c860f16f094e9b3dececeb47be2a94d585 (diff)
downloadphp-waddiwasi-7f3246e4582a488327f2a9da01111db1a4a32b91.tar.gz
php-waddiwasi-7f3246e4582a488327f2a9da01111db1a4a32b91.tar.zst
php-waddiwasi-7f3246e4582a488327f2a9da01111db1a4a32b91.zip
chore: enable common ruleset of ecs
Diffstat (limited to 'src/Stream')
-rw-r--r--src/Stream/BlobStream.php2
-rw-r--r--src/Stream/FileStream.php16
2 files changed, 8 insertions, 10 deletions
diff --git a/src/Stream/BlobStream.php b/src/Stream/BlobStream.php
index 3f8004b..08eed21 100644
--- a/src/Stream/BlobStream.php
+++ b/src/Stream/BlobStream.php
@@ -90,7 +90,7 @@ final class BlobStream implements StreamInterface
private function ensureNBytesAvailable(int $bytes): void
{
if ($this->len < $this->pos + $bytes) {
- throw new UnexpectedEofException(sprintf("Unexpected EOF while reading from blob (%d bytes expected, %d bytes read)", $bytes, $this->len - $this->pos));
+ throw new UnexpectedEofException(sprintf('Unexpected EOF while reading from blob (%d bytes expected, %d bytes read)', $bytes, $this->len - $this->pos));
}
}
}
diff --git a/src/Stream/FileStream.php b/src/Stream/FileStream.php
index 308f617..2f21739 100644
--- a/src/Stream/FileStream.php
+++ b/src/Stream/FileStream.php
@@ -30,7 +30,7 @@ final class FileStream implements StreamInterface
) {
$fp = fopen($path, 'rb');
if ($fp === false) {
- throw new IoException("Failed to open file: $path");
+ throw new IoException("Failed to open file: {$path}");
}
$this->fp = $fp;
}
@@ -47,12 +47,10 @@ final class FileStream implements StreamInterface
$this->peekedByte = null;
if ($bytes === 1) {
return $first;
- } else {
- return $first . $this->doRead($bytes - 1);
}
- } else {
- return $this->doRead($bytes);
+ return $first . $this->doRead($bytes - 1);
}
+ return $this->doRead($bytes);
}
public function readByte(): int
@@ -82,9 +80,9 @@ final class FileStream implements StreamInterface
{
$ret = ftell($this->fp);
if ($ret === false) {
- throw new IoException("Failed to get current position in file: $this->path");
+ throw new IoException("Failed to get current position in file: {$this->path}");
}
- assert(0 <= $ret);
+ assert($ret >= 0);
return $ret;
}
@@ -114,10 +112,10 @@ final class FileStream implements StreamInterface
{
$result = fread($this->fp, $bytes);
if ($result === false) {
- throw new IoException("Failed to read from file: $this->path");
+ throw new IoException("Failed to read from file: {$this->path}");
}
if (strlen($result) < $bytes) {
- throw new UnexpectedEofException(sprintf("Unexpected EOF while reading from file: %s (%d bytes expected, %d bytes read)", $this->path, $bytes, strlen($result)));
+ throw new UnexpectedEofException(sprintf('Unexpected EOF while reading from file: %s (%d bytes expected, %d bytes read)', $this->path, $bytes, strlen($result)));
}
return $result;
}