From 98e724e7be791001dc5e678bd980847173b70cbd Mon Sep 17 00:00:00 2001 From: Thomas Spencer Date: Mon, 30 Jun 2025 13:57:44 +0800 Subject: [PATCH] Fix exception deprecation notice Fixed the following deprecation notice: "Exception::__construct(): Passing null to parameter #2 ($code) of type int is deprecated" --- src/Exceptions/CouldNotSendNotification.php | 16 +++++++--------- tests/ChannelTest.php | 7 +++++++ tests/MessageTest.php | 2 ++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Exceptions/CouldNotSendNotification.php b/src/Exceptions/CouldNotSendNotification.php index a1fe2ca..dd9786d 100644 --- a/src/Exceptions/CouldNotSendNotification.php +++ b/src/Exceptions/CouldNotSendNotification.php @@ -9,21 +9,19 @@ class CouldNotSendNotification extends \Exception private $response; /** - * @param Response $response - * @param string $message - * @param int|null $code + * @param Response $response + * @param string $message + * @param int|null $code */ - public function __construct(Response $response, string $message, int $code = null) + public function __construct(Response $response, string $message, ?int $code = null) { - $this->response = $response; - $this->message = $message; - $this->code = $code ?? $response->getStatusCode(); + parent::__construct($message, $code ?? $response->getStatusCode()); - parent::__construct($message, $code); + $this->response = $response; } /** - * @param Response $response + * @param Response $response * @return self */ public static function serviceRespondedWithAnError(Response $response) diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index 6e57427..1423f2d 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -13,6 +13,13 @@ class ChannelTest extends TestCase { + protected function setUp(): void + { + parent::setUp(); + + $this->withoutDeprecationHandling(); + } + /** @test */ public function it_can_send_a_notification() { diff --git a/tests/MessageTest.php b/tests/MessageTest.php index 3e5a800..1ddf9a7 100644 --- a/tests/MessageTest.php +++ b/tests/MessageTest.php @@ -14,6 +14,8 @@ class MessageTest extends TestCase public function setUp(): void { parent::setUp(); + + $this->withoutDeprecationHandling(); $this->message = new WebhookMessage(); }