From 5868be6d6ac22740aa681fb9a91883d375cd67b0 Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 26 Feb 2020 14:22:19 +0100 Subject: [PATCH 1/2] Don't trigger when default exception is null --- CHANGELOG.md | 4 ++++ src/Client.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f2d75..b2202bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 1.4.0 - +### Fixed +- `reset()` should not trigger `setDefaultException` error condition + +### Breaking - drop support for PHP 5 and 7.0 ## 1.3.1 - 2019-11-06 diff --git a/src/Client.php b/src/Client.php index 33ddde1..da17a88 100644 --- a/src/Client.php +++ b/src/Client.php @@ -176,7 +176,7 @@ public function addException(\Exception $exception) */ public function setDefaultException(\Exception $defaultException = null) { - if (!$defaultException instanceof Exception) { + if ($defaultException !== null && !$defaultException instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->defaultException = $defaultException; From 760af6f47ce6cc8cb06c4955c0db6d0636645bea Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 26 Feb 2020 14:31:57 +0100 Subject: [PATCH 2/2] style CI fix --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index da17a88..1b3782b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -176,7 +176,7 @@ public function addException(\Exception $exception) */ public function setDefaultException(\Exception $defaultException = null) { - if ($defaultException !== null && !$defaultException instanceof Exception) { + if (null !== $defaultException && !$defaultException instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->defaultException = $defaultException;