From 10a13f17d2cfc746f4cceee956d8c3f70686d841 Mon Sep 17 00:00:00 2001 From: Andrii Date: Sun, 1 Sep 2024 14:39:38 +0300 Subject: [PATCH] :package: `fread` requires to pass only `int<1, max>` - early return empty string in case of `0` length --- src/Stream.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Stream.php b/src/Stream.php index 0c059ca..afe6dd6 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -155,9 +155,14 @@ public function isReadable(): bool */ public function read($length): string { + if (0 === $length) { + return ''; + } + if ($this->isDetached || null === $this->socket) { throw new StreamException('Stream is detached'); } + if (null === $this->getSize()) { $read = fread($this->socket, $length); if (false === $read) {