From c9e4f40284687b4fbc2341216fe9657fe2b3e990 Mon Sep 17 00:00:00 2001 From: Matias Vasquez Date: Mon, 7 Oct 2024 13:06:04 -0300 Subject: [PATCH 1/2] feat: disable error reporting just on create body method --- src/Utils/Curl/MessageTrait.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Utils/Curl/MessageTrait.php b/src/Utils/Curl/MessageTrait.php index 9a77ffaa..fe3cb4ef 100644 --- a/src/Utils/Curl/MessageTrait.php +++ b/src/Utils/Curl/MessageTrait.php @@ -78,6 +78,8 @@ public function withAddedHeader($name, $value): static private function createBody($body = ''): StreamInterface { + $oldErrorReporting = error_reporting(); + error_reporting(0); $resource = fopen('php://temp', 'rw+'); if ($resource === false) { throw new CurlRequestException('Unable to open stream'); @@ -90,6 +92,8 @@ private function createBody($body = ''): StreamInterface } } + error_reporting($oldErrorReporting); + return new Stream($resource); } } From 1f807f19a6745ef36b824379637100835db21b6f Mon Sep 17 00:00:00 2001 From: Matias Vasquez Date: Mon, 7 Oct 2024 13:10:08 -0300 Subject: [PATCH 2/2] feat: restore error_reporting after fopen --- src/Utils/Curl/MessageTrait.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Utils/Curl/MessageTrait.php b/src/Utils/Curl/MessageTrait.php index fe3cb4ef..b7419f21 100644 --- a/src/Utils/Curl/MessageTrait.php +++ b/src/Utils/Curl/MessageTrait.php @@ -81,6 +81,7 @@ private function createBody($body = ''): StreamInterface $oldErrorReporting = error_reporting(); error_reporting(0); $resource = fopen('php://temp', 'rw+'); + error_reporting($oldErrorReporting); if ($resource === false) { throw new CurlRequestException('Unable to open stream'); } @@ -92,8 +93,6 @@ private function createBody($body = ''): StreamInterface } } - error_reporting($oldErrorReporting); - return new Stream($resource); } }