Skip to content

Commit 1d23cd5

Browse files
authored
Merge pull request #19 from petrknap/error-suppression
Silenced errors inside coders and serializers
2 parents 96fbb5d + fffc2ae commit 1d23cd5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Coder/Coder.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class Coder implements CoderInterface
1414
public function encode(string $decoded): string
1515
{
1616
try {
17-
return $this->doEncode($decoded);
17+
return @$this->doEncode($decoded);
1818
} catch (Exception\CoderCouldNotEncodeData $exception) {
1919
throw $exception;
2020
} catch (Throwable $reason) {
@@ -25,7 +25,7 @@ public function encode(string $decoded): string
2525
public function decode(string $encoded): string
2626
{
2727
try {
28-
return $this->doDecode($encoded);
28+
return @$this->doDecode($encoded);
2929
} catch (Exception\CoderCouldNotDecodeData $exception) {
3030
throw $exception;
3131
} catch (Throwable $reason) {
@@ -34,11 +34,15 @@ public function decode(string $encoded): string
3434
}
3535

3636
/**
37+
* @note errors will be silenced
38+
*
3739
* @throws Throwable
3840
*/
3941
abstract protected function doEncode(string $decoded): string;
4042

4143
/**
44+
* @note errors will be silenced
45+
*
4246
* @throws Throwable
4347
*/
4448
abstract protected function doDecode(string $encoded): string;

src/Serializer/Serializer.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class Serializer implements SerializerInterface
1414
public function serialize(mixed $serializable): string
1515
{
1616
try {
17-
return $this->doSerialize($serializable);
17+
return @$this->doSerialize($serializable);
1818
} catch (Exception\SerializerCouldNotSerializeData $exception) {
1919
throw $exception;
2020
} catch (Throwable $reason) {
@@ -25,7 +25,7 @@ public function serialize(mixed $serializable): string
2525
public function unserialize(string $serialized): mixed
2626
{
2727
try {
28-
return $this->doUnserialize($serialized);
28+
return @$this->doUnserialize($serialized);
2929
} catch (Exception\SerializerCouldNotUnserializeData $exception) {
3030
throw $exception;
3131
} catch (Throwable $reason) {
@@ -34,11 +34,15 @@ public function unserialize(string $serialized): mixed
3434
}
3535

3636
/**
37+
* @note errors will be silenced
38+
*
3739
* @throws Throwable
3840
*/
3941
abstract protected function doSerialize(mixed $serializable): string;
4042

4143
/**
44+
* @note errors will be silenced
45+
*
4246
* @throws Throwable
4347
*/
4448
abstract protected function doUnserialize(string $serialized): mixed;

0 commit comments

Comments
 (0)