From fffc2ae9ed55825fd177a1c5c40035d6432bb915 Mon Sep 17 00:00:00 2001 From: Petr Knap <8299754+petrknap@users.noreply.github.com> Date: Mon, 7 Apr 2025 21:47:33 +0200 Subject: [PATCH] fix: silenced errors inside coders and serializers --- src/Coder/Coder.php | 8 ++++++-- src/Serializer/Serializer.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Coder/Coder.php b/src/Coder/Coder.php index a8d5e8c..c3fd8ad 100644 --- a/src/Coder/Coder.php +++ b/src/Coder/Coder.php @@ -14,7 +14,7 @@ abstract class Coder implements CoderInterface public function encode(string $decoded): string { try { - return $this->doEncode($decoded); + return @$this->doEncode($decoded); } catch (Exception\CoderCouldNotEncodeData $exception) { throw $exception; } catch (Throwable $reason) { @@ -25,7 +25,7 @@ public function encode(string $decoded): string public function decode(string $encoded): string { try { - return $this->doDecode($encoded); + return @$this->doDecode($encoded); } catch (Exception\CoderCouldNotDecodeData $exception) { throw $exception; } catch (Throwable $reason) { @@ -34,11 +34,15 @@ public function decode(string $encoded): string } /** + * @note errors will be silenced + * * @throws Throwable */ abstract protected function doEncode(string $decoded): string; /** + * @note errors will be silenced + * * @throws Throwable */ abstract protected function doDecode(string $encoded): string; diff --git a/src/Serializer/Serializer.php b/src/Serializer/Serializer.php index dc04275..2a92066 100644 --- a/src/Serializer/Serializer.php +++ b/src/Serializer/Serializer.php @@ -14,7 +14,7 @@ abstract class Serializer implements SerializerInterface public function serialize(mixed $serializable): string { try { - return $this->doSerialize($serializable); + return @$this->doSerialize($serializable); } catch (Exception\SerializerCouldNotSerializeData $exception) { throw $exception; } catch (Throwable $reason) { @@ -25,7 +25,7 @@ public function serialize(mixed $serializable): string public function unserialize(string $serialized): mixed { try { - return $this->doUnserialize($serialized); + return @$this->doUnserialize($serialized); } catch (Exception\SerializerCouldNotUnserializeData $exception) { throw $exception; } catch (Throwable $reason) { @@ -34,11 +34,15 @@ public function unserialize(string $serialized): mixed } /** + * @note errors will be silenced + * * @throws Throwable */ abstract protected function doSerialize(mixed $serializable): string; /** + * @note errors will be silenced + * * @throws Throwable */ abstract protected function doUnserialize(string $serialized): mixed;