diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php index 96e6cc86581a..f97b7c36dfe1 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php @@ -36,7 +36,7 @@ final class TelegramTransport extends AbstractTransport private string $token; private ?string $chatChannel; - public const EXCLUSIVE_OPTIONS = [ + private const EXCLUSIVE_OPTIONS = [ 'message_id', 'callback_query_id', 'photo', diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php index 497c0c957f5c..b5a4f887d2e0 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php @@ -1242,6 +1242,6 @@ public function testUsingMultipleExclusiveOptionsWillProvideExceptions(TelegramO $transport = self::createTransport($client, 'testChannel'); $this->expectException(MultipleExclusiveOptionsUsedException::class); - $sentMessage = $transport->send(new ChatMessage('', $messageOptions)); + $transport->send(new ChatMessage('', $messageOptions)); } } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json index b81a30da1fb0..c1a4499c589a 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/composer.json @@ -17,8 +17,9 @@ ], "require": { "php": ">=8.1", - "symfony/http-client": "^5.4|^6.0|^7.0", - "symfony/notifier": "^6.2.7|^7.0" + "symfony/http-client": "^6.3|^7.0", + "symfony/mime": "^5.4|^6.3|^7.0", + "symfony/notifier": "^6.4|^7.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Telegram\\": "" }, diff --git a/src/Symfony/Component/Notifier/Exception/MultipleExclusiveOptionsUsedException.php b/src/Symfony/Component/Notifier/Exception/MultipleExclusiveOptionsUsedException.php index 738956f229d0..418b32dabe8b 100644 --- a/src/Symfony/Component/Notifier/Exception/MultipleExclusiveOptionsUsedException.php +++ b/src/Symfony/Component/Notifier/Exception/MultipleExclusiveOptionsUsedException.php @@ -17,15 +17,16 @@ class MultipleExclusiveOptionsUsedException extends InvalidArgumentException { /** - * @param string[] $usedExclusiveOptions - * @param string[]|null $exclusiveOptions + * @param string[] $usedExclusiveOptions + * @param string[] $exclusiveOptions */ - public function __construct(array $usedExclusiveOptions, array $exclusiveOptions = null, \Throwable $previous = null) + public function __construct(array $usedExclusiveOptions, array $exclusiveOptions, \Throwable $previous = null) { - $message = sprintf('Multiple exclusive options have been used "%s".', implode('", "', $usedExclusiveOptions)); - if (null !== $exclusiveOptions) { - $message .= sprintf(' Only one of %s can be used.', implode('", "', $exclusiveOptions)); - } + $message = sprintf( + 'Multiple exclusive options have been used "%s". Only one of "%s" can be used.', + implode('", "', $usedExclusiveOptions), + implode('", "', $exclusiveOptions) + ); parent::__construct($message, 0, $previous); } diff --git a/src/Symfony/Component/Notifier/Tests/Exception/MultipleExclusiveOptionsUsedExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/MultipleExclusiveOptionsUsedExceptionTest.php new file mode 100644 index 000000000000..cef0467d6528 --- /dev/null +++ b/src/Symfony/Component/Notifier/Tests/Exception/MultipleExclusiveOptionsUsedExceptionTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Tests\Exception; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Notifier\Exception\MultipleExclusiveOptionsUsedException; + +class MultipleExclusiveOptionsUsedExceptionTest extends TestCase +{ + public function testMessage() + { + $exception = new MultipleExclusiveOptionsUsedException(['foo', 'bar'], ['foo', 'bar', 'baz']); + + $this->assertSame( + 'Multiple exclusive options have been used "foo", "bar". Only one of "foo", "bar", "baz" can be used.', + $exception->getMessage() + ); + } +}