Skip to content

Commit 10a13f1

Browse files
committed
📦 fread requires to pass only int<1, max> - early return empty string in case of 0 length
1 parent eebe6b0 commit 10a13f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Stream.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,14 @@ public function isReadable(): bool
155155
*/
156156
public function read($length): string
157157
{
158+
if (0 === $length) {
159+
return '';
160+
}
161+
158162
if ($this->isDetached || null === $this->socket) {
159163
throw new StreamException('Stream is detached');
160164
}
165+
161166
if (null === $this->getSize()) {
162167
$read = fread($this->socket, $length);
163168
if (false === $read) {

0 commit comments

Comments
 (0)