From 078057f6bbe1221ece57b7476cfe14944087fa25 Mon Sep 17 00:00:00 2001 From: Evgeniy Zyubin Date: Wed, 15 Nov 2023 22:47:58 +0300 Subject: [PATCH] Fix code sniffer --- src/StreamTrait.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/StreamTrait.php b/src/StreamTrait.php index 84f8895..1509a5a 100644 --- a/src/StreamTrait.php +++ b/src/StreamTrait.php @@ -335,15 +335,16 @@ public function getContents(): string } $exception = null; + $message = 'Unable to read stream contents'; - set_error_handler(static function ($type, $message) use (&$exception) { - throw $exception = new RuntimeException('Unable to read stream contents: ' . $message); + set_error_handler(static function (int $errno, string $errstr) use (&$exception, $message) { + throw $exception = new RuntimeException("$message: $errstr"); }); try { return stream_get_contents($this->resource); } catch (Throwable $e) { - throw $e === $exception ? $e : new RuntimeException('Unable to read stream contents: ' . $e->getMessage(), 0, $e); + throw $e === $exception ? $e : new RuntimeException("$message: {$e->getMessage()}", 0, $e); } finally { restore_error_handler(); }