Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94a156f

Browse filesBrowse files
committed
minor #59234 [Notifier] unsupported options exception (raphael-geffroy)
This PR was squashed before being merged into the 7.3 branch. Discussion ---------- [Notifier] unsupported options exception | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix #59120 | License | MIT Streamline one more exception for the bridges regarding option classes. Commits ------- 27dfb8c [Notifier] unsupported options exception
2 parents dd882db + 27dfb8c commit 94a156f
Copy full SHA for 94a156f

File tree

Expand file treeCollapse file tree

14 files changed

+49
-22
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+49
-22
lines changed

‎src/Symfony/Component/Notifier/Bridge/GoIp/GoIpTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoIp/GoIpTransport.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Notifier\Exception\LogicException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
1616
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1718
use Symfony\Component\Notifier\Message\MessageInterface;
1819
use Symfony\Component\Notifier\Message\SentMessage;
1920
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -63,7 +64,7 @@ protected function doSend(MessageInterface $message): SentMessage
6364
}
6465

6566
if (($options = $message->getOptions()) && !$options instanceof GoIpOptions) {
66-
throw new LogicException(\sprintf('The "%s" transport only supports an instance of the "%s" as an option class.', __CLASS__, GoIpOptions::class));
67+
throw new UnsupportedOptionsException(__CLASS__, GoIpOptions::class, $options);
6768
}
6869

6970
if ('' !== $message->getFrom()) {

‎src/Symfony/Component/Notifier/Bridge/GoIp/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoIp/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/http-client": "^6.4|^7.0",
21-
"symfony/notifier": "^7.2"
21+
"symfony/notifier": "^7.3"
2222
},
2323
"autoload": {
2424
"psr-4": {

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace Symfony\Component\Notifier\Bridge\GoogleChat;
1313

1414
use Symfony\Component\HttpClient\Exception\JsonException;
15-
use Symfony\Component\Notifier\Exception\LogicException;
1615
use Symfony\Component\Notifier\Exception\TransportException;
1716
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1818
use Symfony\Component\Notifier\Message\ChatMessage;
1919
use Symfony\Component\Notifier\Message\MessageInterface;
2020
use Symfony\Component\Notifier\Message\SentMessage;
@@ -74,7 +74,7 @@ protected function doSend(MessageInterface $message): SentMessage
7474
}
7575

7676
if (($options = $message->getOptions()) && !$options instanceof GoogleChatOptions) {
77-
throw new LogicException(\sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, GoogleChatOptions::class));
77+
throw new UnsupportedOptionsException(__CLASS__, GoogleChatOptions::class, $options);
7878
}
7979

8080
if (!$options) {

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatTransportTest.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use Symfony\Component\HttpClient\MockHttpClient;
1515
use Symfony\Component\Notifier\Bridge\GoogleChat\GoogleChatOptions;
1616
use Symfony\Component\Notifier\Bridge\GoogleChat\GoogleChatTransport;
17-
use Symfony\Component\Notifier\Exception\LogicException;
1817
use Symfony\Component\Notifier\Exception\TransportException;
18+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1919
use Symfony\Component\Notifier\Message\ChatMessage;
2020
use Symfony\Component\Notifier\Message\MessageOptionsInterface;
2121
use Symfony\Component\Notifier\Message\SmsMessage;
@@ -159,14 +159,15 @@ public function testSendWithNotification()
159159

160160
public function testSendWithInvalidOptions()
161161
{
162-
$this->expectException(LogicException::class);
163-
$this->expectExceptionMessage('The "'.GoogleChatTransport::class.'" transport only supports instances of "'.GoogleChatOptions::class.'" for options.');
162+
$options = $this->createMock(MessageOptionsInterface::class);
163+
$this->expectException(UnsupportedOptionsException::class);
164+
$this->expectExceptionMessage(\sprintf('The "%s" transport only supports instances of "%s" for options (instance of "%s" given).', GoogleChatTransport::class, GoogleChatOptions::class, get_debug_type($options)));
164165

165166
$client = new MockHttpClient(fn (string $method, string $url, array $options = []): ResponseInterface => $this->createMock(ResponseInterface::class));
166167

167168
$transport = self::createTransport($client);
168169

169-
$transport->send(new ChatMessage('testMessage', $this->createMock(MessageOptionsInterface::class)));
170+
$transport->send(new ChatMessage('testMessage', $options));
170171
}
171172

172173
public function testSendWith200ResponseButNotOk()

‎src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/http-client": "^6.4|^7.0",
21-
"symfony/notifier": "^7.2"
21+
"symfony/notifier": "^7.3"
2222
},
2323
"autoload": {
2424
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\GoogleChat\\": "" },

‎src/Symfony/Component/Notifier/Bridge/JoliNotif/JoliNotifTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/JoliNotif/JoliNotifTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
use Joli\JoliNotif\DefaultNotifier as JoliNotifier;
1515
use Joli\JoliNotif\Notification as JoliNotification;
16-
use Symfony\Component\Notifier\Exception\LogicException;
1716
use Symfony\Component\Notifier\Exception\RuntimeException;
1817
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
18+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1919
use Symfony\Component\Notifier\Message\DesktopMessage;
2020
use Symfony\Component\Notifier\Message\MessageInterface;
2121
use Symfony\Component\Notifier\Message\SentMessage;
@@ -51,7 +51,7 @@ protected function doSend(MessageInterface $message): SentMessage
5151
}
5252

5353
if (($options = $message->getOptions()) && !$options instanceof JoliNotifOptions) {
54-
throw new LogicException(\sprintf('The "%s" transport only supports an instance of the "%s" as an option class.', __CLASS__, JoliNotifOptions::class));
54+
throw new UnsupportedOptionsException(__CLASS__, JoliNotifOptions::class, $options);
5555
}
5656

5757
$joliNotification = $this->buildJoliNotificationObject($message, $options);

‎src/Symfony/Component/Notifier/Bridge/JoliNotif/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/JoliNotif/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"php": ">=8.2",
2525
"jolicode/jolinotif": "^2.7.2|^3.0",
2626
"symfony/http-client": "^7.2",
27-
"symfony/notifier": "^7.2"
27+
"symfony/notifier": "^7.3"
2828
},
2929
"autoload": {
3030
"psr-4": {

‎src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/LinkedIn/LinkedInTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace Symfony\Component\Notifier\Bridge\LinkedIn;
1313

1414
use Symfony\Component\Notifier\Bridge\LinkedIn\Share\AuthorShare;
15-
use Symfony\Component\Notifier\Exception\LogicException;
1615
use Symfony\Component\Notifier\Exception\TransportException;
1716
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
17+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1818
use Symfony\Component\Notifier\Message\ChatMessage;
1919
use Symfony\Component\Notifier\Message\MessageInterface;
2020
use Symfony\Component\Notifier\Message\SentMessage;
@@ -61,7 +61,7 @@ protected function doSend(MessageInterface $message): SentMessage
6161
}
6262

6363
if (($options = $message->getOptions()) && !$options instanceof LinkedInOptions) {
64-
throw new LogicException(\sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, LinkedInOptions::class));
64+
throw new UnsupportedOptionsException(__CLASS__, LinkedInOptions::class, $options);
6565
}
6666

6767
if (!$options && $notification = $message->getNotification()) {

‎src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/LinkedIn/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/http-client": "^6.4|^7.0",
21-
"symfony/notifier": "^7.2"
21+
"symfony/notifier": "^7.3"
2222
},
2323
"autoload": {
2424
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\LinkedIn\\": "" },

‎src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Mercure/MercureTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Symfony\Component\Mercure\Exception\RuntimeException as MercureRuntimeException;
1616
use Symfony\Component\Mercure\HubInterface;
1717
use Symfony\Component\Mercure\Update;
18-
use Symfony\Component\Notifier\Exception\LogicException;
1918
use Symfony\Component\Notifier\Exception\RuntimeException;
2019
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
20+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
2121
use Symfony\Component\Notifier\Message\ChatMessage;
2222
use Symfony\Component\Notifier\Message\MessageInterface;
2323
use Symfony\Component\Notifier\Message\SentMessage;
@@ -67,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage
6767
}
6868

6969
if (($options = $message->getOptions()) && !$options instanceof MercureOptions) {
70-
throw new LogicException(\sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, MercureOptions::class));
70+
throw new UnsupportedOptionsException(__CLASS__, MercureOptions::class, $options);
7171
}
7272

7373
$options ??= new MercureOptions($this->topics);

‎src/Symfony/Component/Notifier/Bridge/Mercure/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Mercure/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/mercure": "^0.5.2|^0.6",
21-
"symfony/notifier": "^7.2",
21+
"symfony/notifier": "^7.3",
2222
"symfony/service-contracts": "^2.5|^3"
2323
},
2424
"autoload": {

‎src/Symfony/Component/Notifier/Bridge/Ntfy/NtfyTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Ntfy/NtfyTransport.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Ntfy;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
1615
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
16+
use Symfony\Component\Notifier\Exception\UnsupportedOptionsException;
1717
use Symfony\Component\Notifier\Message\MessageInterface;
1818
use Symfony\Component\Notifier\Message\PushMessage;
1919
use Symfony\Component\Notifier\Message\SentMessage;
@@ -65,8 +65,8 @@ protected function doSend(MessageInterface $message): SentMessage
6565
throw new UnsupportedMessageTypeException(__CLASS__, PushMessage::class, $message);
6666
}
6767

68-
if ($message->getOptions() && !$message->getOptions() instanceof NtfyOptions) {
69-
throw new LogicException(\sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, NtfyOptions::class));
68+
if (($options = $message->getOptions()) && !$message->getOptions() instanceof NtfyOptions) {
69+
throw new UnsupportedOptionsException(__CLASS__, NtfyOptions::class, $options);
7070
}
7171

7272
if (!($opts = $message->getOptions()) && $notification = $message->getNotification()) {

‎src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=8.2",
2020
"symfony/clock": "^6.4|^7.0",
2121
"symfony/http-client": "^6.4|^7.0",
22-
"symfony/notifier": "^7.2"
22+
"symfony/notifier": "^7.3"
2323
},
2424
"autoload": {
2525
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Ntfy\\": "" },
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Exception;
13+
14+
use Symfony\Component\Notifier\Message\MessageOptionsInterface;
15+
16+
/**
17+
* @author Raphaël Geffroy <raphael@geffroy.dev>
18+
*/
19+
class UnsupportedOptionsException extends LogicException
20+
{
21+
public function __construct(string $transport, string $supported, MessageOptionsInterface $given)
22+
{
23+
parent::__construct(\sprintf('The "%s" transport only supports instances of "%s" for options (instance of "%s" given).', $transport, $supported, get_debug_type($given)));
24+
}
25+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.