Skip to content

Commit 98e724e

Browse files
committed
Fix exception deprecation notice
Fixed the following deprecation notice: "Exception::__construct(): Passing null to parameter #2 ($code) of type int is deprecated"
1 parent b322bbd commit 98e724e

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/Exceptions/CouldNotSendNotification.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ class CouldNotSendNotification extends \Exception
99
private $response;
1010

1111
/**
12-
* @param Response $response
13-
* @param string $message
14-
* @param int|null $code
12+
* @param Response $response
13+
* @param string $message
14+
* @param int|null $code
1515
*/
16-
public function __construct(Response $response, string $message, int $code = null)
16+
public function __construct(Response $response, string $message, ?int $code = null)
1717
{
18-
$this->response = $response;
19-
$this->message = $message;
20-
$this->code = $code ?? $response->getStatusCode();
18+
parent::__construct($message, $code ?? $response->getStatusCode());
2119

22-
parent::__construct($message, $code);
20+
$this->response = $response;
2321
}
2422

2523
/**
26-
* @param Response $response
24+
* @param Response $response
2725
* @return self
2826
*/
2927
public static function serviceRespondedWithAnError(Response $response)

tests/ChannelTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
class ChannelTest extends TestCase
1515
{
16+
protected function setUp(): void
17+
{
18+
parent::setUp();
19+
20+
$this->withoutDeprecationHandling();
21+
}
22+
1623
/** @test */
1724
public function it_can_send_a_notification()
1825
{

tests/MessageTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class MessageTest extends TestCase
1414
public function setUp(): void
1515
{
1616
parent::setUp();
17+
18+
$this->withoutDeprecationHandling();
1719
$this->message = new WebhookMessage();
1820
}
1921

0 commit comments

Comments
 (0)