From 830ced65f1f30840279df9378ee2de988faf6bd7 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 7 Jul 2017 21:09:08 +0200 Subject: [PATCH 1/2] Make sure __toString does not throw exception --- src/Stream.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Stream.php b/src/Stream.php index 9f5677f..3636cc7 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -59,7 +59,15 @@ public function __construct($socket, $size = null) */ public function __toString() { - return (string) $this->getContents(); + try { + if ($this->isSeekable()) { + $this->seek(0); + } + + return $this->getContents(); + } catch (\Exception $e) { + return ''; + } } /** From 2472f43bc8b884c6a92300ae4b6b83a0db1c66a1 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 7 Jul 2017 21:28:23 +0200 Subject: [PATCH 2/2] Bugfix --- src/Stream.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Stream.php b/src/Stream.php index 3636cc7..507f135 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -60,10 +60,6 @@ public function __construct($socket, $size = null) public function __toString() { try { - if ($this->isSeekable()) { - $this->seek(0); - } - return $this->getContents(); } catch (\Exception $e) { return '';