diff options
Diffstat (limited to 'src/Stream')
| -rw-r--r-- | src/Stream/BlobStream.php | 2 | ||||
| -rw-r--r-- | src/Stream/FileStream.php | 16 |
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; } |
