diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php index 1ad292c17c136..4a89e6819878d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } $messageOptions = $message->getOptions(); diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php index 097b1ad25caf8..c42a3c6d205a9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php @@ -14,8 +14,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Discord\DiscordTransport; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -43,9 +43,10 @@ public function testSupportsChatMessage() public function testSendNonChatMessageThrows() { - $this->expectException(LogicException::class); $transport = new DiscordTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class)); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/composer.json b/src/Symfony/Component/Notifier/Bridge/Discord/composer.json index a47bc90ac9620..72987e5a9fd42 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Discord/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "require-dev": { "symfony/event-dispatcher": "^4.3|^5.0" diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php index bc8c7a6207e1b..521bbe3a3ceda 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/EsendexTransport.php @@ -13,8 +13,8 @@ use Symfony\Component\HttpClient\Exception\JsonException; use Symfony\Component\HttpClient\Exception\TransportException as HttpClientTransportException; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $messageData = [ diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php index 09bf2844acc7b..3242739119be3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/Tests/EsendexTransportTest.php @@ -14,8 +14,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Esendex\EsendexTransport; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -43,7 +43,8 @@ public function testSendNonSmsMessageThrows(): void { $transport = new EsendexTransport('testToken', 'accountReference', 'from', $this->createMock(HttpClientInterface::class)); - $this->expectException(LogicException::class); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json b/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json index cb0404171cc17..6358037b60394 100644 --- a/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Esendex/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.4|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Esendex\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php b/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php index 4734ad4ea0674..77d4baef0f2d3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php @@ -12,8 +12,8 @@ namespace Symfony\Component\Notifier\Bridge\Firebase; use Symfony\Component\Notifier\Exception\InvalidArgumentException; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } $endpoint = sprintf('https://%s', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json b/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json index a8d4c83afe912..782c5239be47b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Firebase/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Firebase\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php index 2113b014d7143..4da92c2fc4a6a 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\FreeMobile; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$this->supports($message)) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given) and configured with your phone number.', __CLASS__, SmsMessage::class, \get_class($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $response = $this->client->request('POST', $this->getEndpoint(), [ diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php index e893de743408b..9b05e02f02daf 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Notifier\Bridge\FreeMobile\FreeMobileTransport; -use Symfony\Component\Notifier\Exception\LogicException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -46,7 +46,7 @@ public function testSendNonSmsMessageThrowsException(): void { $transport = $this->getTransport('0611223344'); - $this->expectException(LogicException::class); + $this->expectException(UnsupportedMessageTypeException::class); $transport->send($this->createMock(MessageInterface::class)); } @@ -55,7 +55,7 @@ public function testSendSmsMessageButInvalidPhoneThrowsException(): void { $transport = $this->getTransport('0611223344'); - $this->expectException(LogicException::class); + $this->expectException(UnsupportedMessageTypeException::class); $transport->send(new SmsMessage('0699887766', 'Hello!')); } diff --git a/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json b/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json index cfc329d93446b..36d7277c44f80 100644 --- a/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/FreeMobile/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.1", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\FreeMobile\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php b/src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php index 9037644d60345..38a7910122216 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpClient\Exception\JsonException; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -87,7 +88,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof GoogleChatOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, GoogleChatOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php index cf6e65d19077f..9a959a8625ae6 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Notifier\Bridge\GoogleChat\GoogleChatTransport; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; @@ -44,10 +45,10 @@ public function testSupportsChatMessage(): void public function testSendNonChatMessageThrows(): void { - $this->expectException(LogicException::class); - $transport = new GoogleChatTransport('My-Space', 'theAccessKey', 'theAccessToken=', $this->createMock(HttpClientInterface::class)); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json b/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json index cc6bb5de4402e..cb24cfc52fd6a 100644 --- a/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\GoogleChat\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php b/src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php index f25a8a98862a7..82880eaf83cf0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/InfobipTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Infobip; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $endpoint = sprintf('https://%s/sms/2/text/advanced', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json b/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json index 579f059b77906..00d7e4386b7ed 100644 --- a/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Infobip/composer.json @@ -22,7 +22,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Infobip\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php b/src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php index ae078b25e64c3..970c28addfd24 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php @@ -14,6 +14,7 @@ use Symfony\Component\Notifier\Bridge\LinkedIn\Share\AuthorShare; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -61,7 +62,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, \get_class($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof LinkedInOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, LinkedInOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php index 82ff0cde5df45..4f0bdc058a45d 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/Tests/LinkedInTransportTest.php @@ -7,6 +7,7 @@ use Symfony\Component\Notifier\Bridge\LinkedIn\LinkedInTransport; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; @@ -31,10 +32,10 @@ public function testSupportsChatMessage(): void public function testSendNonChatMessageThrows(): void { - $this->expectException(LogicException::class); - $transport = $this->getTransport(); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json b/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json index 3210cae14e56d..36e10ccf5699b 100644 --- a/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\LinkedIn\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php index c27df25a3526f..1ceba9a8ef105 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/MattermostTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Mattermost; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -54,7 +54,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } $endpoint = sprintf('https://%s/api/v4/posts', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json b/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json index b35bb906ae5aa..9f94864b3bc12 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mattermost/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Mattermost\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php b/src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php index 15604438576f1..320f83535c89e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/MobytTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, \get_class($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof MobytOptions) { diff --git a/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json b/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json index 96a59c8a53174..6bfe03089afa7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Mobyt/composer.json @@ -19,7 +19,7 @@ "ext-json": "*", "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Mobyt\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php index 5451fc8af47d4..528da637ae362 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Nexmo; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [ diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json index f6f795fd5c538..74cf98d8cc1fb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Nexmo\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php index 8d71d23b4a69c..1611d3c76ddb6 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\OvhCloud; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -57,7 +57,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $endpoint = sprintf('https://%s/1.0/sms/%s/jobs', $this->getEndpoint(), $this->serviceName); diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json b/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json index 14149d6eec834..7030cb30143d0 100644 --- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\OvhCloud\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php index 737aaa1b99c9f..f78b1cbcd9c06 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof RocketChatOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, RocketChatOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json b/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json index 1eb4a83e0d2ce..823f51d02cef6 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\RocketChat\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php b/src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php index 70b62e78d7a87..46f35e825f5d8 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/SendinblueTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Sendinblue; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -53,7 +53,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/transactionalSMS/sms', [ diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php index 7c418edef8745..b283b1fa20552 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/Tests/SendinblueTransportTest.php @@ -14,8 +14,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Sendinblue\SendinblueTransport; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -42,7 +42,8 @@ public function testSendNonSmsMessageThrowsException(): void { $transport = $this->initTransport(); - $this->expectException(LogicException::class); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json b/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json index ed0ff3147025a..64b4668669e16 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Sendinblue/composer.json @@ -19,7 +19,7 @@ "ext-json": "*", "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Sendinblue\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php b/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php index e14925764a491..9f4ecd03f730f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/SinchTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Sinch; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $endpoint = sprintf('https://%s/xms/v1/%s/batches', $this->getEndpoint(), $this->accountSid); diff --git a/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json b/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json index ba07c5a4e8817..6ff9d8e282ea0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Sinch/composer.json @@ -19,7 +19,7 @@ "php": ">=7.2.5", "ext-json": "*", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Sinch\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php index 71f67139ec784..bdebd2a3fda26 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/SlackTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -57,7 +58,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof SlackOptions) { throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, SlackOptions::class)); diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php index 3c9f92c87c164..12db5d609766f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Slack/Tests/SlackTransportTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Notifier\Bridge\Slack\SlackTransport; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\MessageOptionsInterface; @@ -47,10 +48,10 @@ public function testSupportsChatMessage(): void public function testSendNonChatMessageThrows(): void { - $this->expectException(LogicException::class); - $transport = new SlackTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class)); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json index 72acfe811be6d..24f0287d41bbe 100644 --- a/src/Symfony/Component/Notifier/Bridge/Slack/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Slack/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "require-dev": { "symfony/event-dispatcher": "^4.3|^5.0" diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php index 0abf6ee3fb7d0..0451fe768e981 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/SmsapiTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Smsapi; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -52,7 +52,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $endpoint = sprintf('https://%s/sms.do', $this->getEndpoint()); diff --git a/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json b/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json index 4df836c7ec00a..28564eaa91c96 100644 --- a/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Smsapi/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Smsapi\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php index a0ca53232e54d..ba953cbd1c81d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -62,7 +63,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if ($message->getOptions() && !$message->getOptions() instanceof TelegramOptions) { diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php index c9e759a52d5c1..f856df6c38083 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php @@ -15,8 +15,8 @@ use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions; use Symfony\Component\Notifier\Bridge\Telegram\TelegramTransport; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -44,9 +44,10 @@ public function testSupportsChatMessage(): void public function testSendNonChatMessageThrows(): void { - $this->expectException(LogicException::class); $transport = new TelegramTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class)); + $this->expectException(UnsupportedMessageTypeException::class); + $transport->send($this->createMock(MessageInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json index 404aec345055d..ffca90186448a 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "require-dev": { "symfony/event-dispatcher": "^4.3|^5.0" diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php b/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php index dd0a5858f3e54..1a0869de211a0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/TwilioTransport.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Twilio; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; use Symfony\Component\Notifier\Message\SmsMessage; @@ -55,7 +55,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof SmsMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, SmsMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); } $endpoint = sprintf('https://%s/2010-04-01/Accounts/%s/Messages.json', $this->getEndpoint(), $this->accountSid); diff --git a/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json b/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json index c28ae88b91877..04bc30f7306ca 100644 --- a/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Twilio/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Twilio\\": "" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php b/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php index 61cee7bb61fb2..c43a1660aa03f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/ZulipTransport.php @@ -13,6 +13,7 @@ use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage; @@ -56,7 +57,7 @@ public function supports(MessageInterface $message): bool protected function doSend(MessageInterface $message): SentMessage { if (!$message instanceof ChatMessage) { - throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given).', __CLASS__, ChatMessage::class, get_debug_type($message))); + throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class, $message); } if (null !== $message->getOptions() && !($message->getOptions() instanceof ZulipOptions)) { diff --git a/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json b/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json index 77fe8b5257508..b96a349288591 100644 --- a/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Zulip/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/http-client": "^4.3|^5.0", - "symfony/notifier": "^5.2" + "symfony/notifier": "^5.3" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Zulip\\": "" }, diff --git a/src/Symfony/Component/Notifier/Exception/UnsupportedMessageTypeException.php b/src/Symfony/Component/Notifier/Exception/UnsupportedMessageTypeException.php new file mode 100644 index 0000000000000..d52ce21417c50 --- /dev/null +++ b/src/Symfony/Component/Notifier/Exception/UnsupportedMessageTypeException.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Exception; + +use Symfony\Component\Notifier\Message\MessageInterface; + +/** + * @author Oskar Stark + * + * @experimental in 5.3 + */ +class UnsupportedMessageTypeException extends LogicException +{ + public function __construct(string $transport, string $supported, MessageInterface $given) + { + $message = sprintf( + 'The "%s" transport only supports instances of "%s" (instance of "%s" given).', + $transport, + $supported, + get_debug_type($given) + ); + + parent::__construct($message); + } +} diff --git a/src/Symfony/Component/Notifier/Transport/TransportInterface.php b/src/Symfony/Component/Notifier/Transport/TransportInterface.php index 1ab2ff4c7443d..812b03919ed87 100644 --- a/src/Symfony/Component/Notifier/Transport/TransportInterface.php +++ b/src/Symfony/Component/Notifier/Transport/TransportInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Notifier\Transport; use Symfony\Component\Notifier\Exception\TransportExceptionInterface; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\SentMessage;