From 1a36657ffdca29ac99f7facea6520f9eb52c3da1 Mon Sep 17 00:00:00 2001 From: Evan Burrell Date: Mon, 20 Jan 2025 16:51:46 +0000 Subject: [PATCH] PHP 8.4 - Deprecation Warnings --- src/Slack/BlockKit/Blocks/ContextBlock.php | 2 +- src/Slack/BlockKit/Blocks/HeaderBlock.php | 2 +- src/Slack/BlockKit/Blocks/ImageBlock.php | 2 +- src/Slack/BlockKit/Elements/ButtonElement.php | 4 ++-- src/Slack/BlockKit/Elements/ImageElement.php | 2 +- src/Slack/SlackMessage.php | 4 ++-- src/Slack/SlackRoute.php | 4 ++-- tests/Slack/SlackChannelTestNotification.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Slack/BlockKit/Blocks/ContextBlock.php b/src/Slack/BlockKit/Blocks/ContextBlock.php index 7deb576..09bd2cf 100644 --- a/src/Slack/BlockKit/Blocks/ContextBlock.php +++ b/src/Slack/BlockKit/Blocks/ContextBlock.php @@ -42,7 +42,7 @@ public function id(string $id): self /** * Add an image element to the block. */ - public function image(string $imageUrl, string $altText = null): ImageElement + public function image(string $imageUrl, ?string $altText = null): ImageElement { return tap(new ImageElement($imageUrl, $altText), function (ImageElement $element) { $this->elements[] = $element; diff --git a/src/Slack/BlockKit/Blocks/HeaderBlock.php b/src/Slack/BlockKit/Blocks/HeaderBlock.php index 688dfea..21fecbc 100644 --- a/src/Slack/BlockKit/Blocks/HeaderBlock.php +++ b/src/Slack/BlockKit/Blocks/HeaderBlock.php @@ -28,7 +28,7 @@ class HeaderBlock implements BlockContract /** * Create a new header block instance. */ - public function __construct(string $text, Closure $callback = null) + public function __construct(string $text, ?Closure $callback = null) { $this->text = $object = new PlainTextOnlyTextObject($text, 150); diff --git a/src/Slack/BlockKit/Blocks/ImageBlock.php b/src/Slack/BlockKit/Blocks/ImageBlock.php index 61d3ce1..c8b1f53 100644 --- a/src/Slack/BlockKit/Blocks/ImageBlock.php +++ b/src/Slack/BlockKit/Blocks/ImageBlock.php @@ -42,7 +42,7 @@ class ImageBlock implements BlockContract /** * Create a new image block instance. */ - public function __construct(string $url, string $altText = null) + public function __construct(string $url, ?string $altText = null) { if (strlen($url) > 3000) { throw new InvalidArgumentException('Maximum length for the url field is 3000 characters.'); diff --git a/src/Slack/BlockKit/Elements/ButtonElement.php b/src/Slack/BlockKit/Elements/ButtonElement.php index c099011..23c80a6 100644 --- a/src/Slack/BlockKit/Elements/ButtonElement.php +++ b/src/Slack/BlockKit/Elements/ButtonElement.php @@ -79,7 +79,7 @@ class ButtonElement implements ElementContract /** * Create a new button element instance. */ - public function __construct(string $text, Closure $callback = null) + public function __construct(string $text, ?Closure $callback = null) { $this->text = new PlainTextOnlyTextObject($text, 75); @@ -155,7 +155,7 @@ public function danger(): self /** * Set the confirm object for the button. */ - public function confirm(string $text, Closure $callback = null): ConfirmObject + public function confirm(string $text, ?Closure $callback = null): ConfirmObject { $this->confirm = $confirm = new ConfirmObject($text); diff --git a/src/Slack/BlockKit/Elements/ImageElement.php b/src/Slack/BlockKit/Elements/ImageElement.php index ef5d037..0b1d044 100644 --- a/src/Slack/BlockKit/Elements/ImageElement.php +++ b/src/Slack/BlockKit/Elements/ImageElement.php @@ -20,7 +20,7 @@ class ImageElement implements ElementContract /** * Create a new image element instance. */ - public function __construct(string $url, string $altText = null) + public function __construct(string $url, ?string $altText = null) { $this->url = $url; $this->altText = $altText; diff --git a/src/Slack/SlackMessage.php b/src/Slack/SlackMessage.php index acc3efa..3c460cf 100644 --- a/src/Slack/SlackMessage.php +++ b/src/Slack/SlackMessage.php @@ -139,7 +139,7 @@ public function dividerBlock(): self /** * Add a new Header block to the message. */ - public function headerBlock(string $text, Closure $callback = null): self + public function headerBlock(string $text, ?Closure $callback = null): self { $this->blocks[] = new HeaderBlock($text, $callback); @@ -149,7 +149,7 @@ public function headerBlock(string $text, Closure $callback = null): self /** * Add a new Image block to the message. */ - public function imageBlock(string $url, Closure|string $altText = null, Closure $callback = null): self + public function imageBlock(string $url, Closure|string|null $altText = null, ?Closure $callback = null): self { if ($altText instanceof Closure) { $callback = $altText; diff --git a/src/Slack/SlackRoute.php b/src/Slack/SlackRoute.php index a08ee6a..9927258 100644 --- a/src/Slack/SlackRoute.php +++ b/src/Slack/SlackRoute.php @@ -21,7 +21,7 @@ class SlackRoute /** * Create a new Slack route instance. */ - public function __construct(string $channel = null, string $token = null) + public function __construct(?string $channel = null, ?string $token = null) { $this->channel = $channel; $this->token = $token; @@ -30,7 +30,7 @@ public function __construct(string $channel = null, string $token = null) /** * Fluently create a new Slack route instance. */ - public static function make(string $channel = null, string $token = null): self + public static function make(?string $channel = null, ?string $token = null): self { return new self($channel, $token); } diff --git a/tests/Slack/SlackChannelTestNotification.php b/tests/Slack/SlackChannelTestNotification.php index ad4c7ec..f867b17 100644 --- a/tests/Slack/SlackChannelTestNotification.php +++ b/tests/Slack/SlackChannelTestNotification.php @@ -10,7 +10,7 @@ class SlackChannelTestNotification extends Notification { private Closure $callback; - public function __construct(Closure $callback = null) + public function __construct(?Closure $callback = null) { $this->callback = $callback ?? function () { //