Skip to content

Commit 557f0f6

Browse files
committed
Make sure __toString does not throw exception
1 parent a6bfe1b commit 557f0f6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Stream.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ public function __construct($socket, $size = null)
5959
*/
6060
public function __toString()
6161
{
62-
return (string) $this->getContents();
62+
try {
63+
if ($this->isSeekable()) {
64+
$this->seek(0);
65+
}
66+
67+
return $this->getContents();
68+
} catch (\Exception $e) {
69+
return '';
70+
}
6371
}
6472

6573
/**

0 commit comments

Comments
 (0)