From 193ca10fe319db270acfed11543214e6f1c6fcae Mon Sep 17 00:00:00 2001 From: Mihail Kezin Date: Fri, 7 Nov 2025 16:39:04 +0200 Subject: [PATCH 1/2] Chore: Fix symfony/console deprecations --- src/Command/ButtonDeleteCommand.php | 15 +++++---------- src/Command/ButtonUpdateCommand.php | 15 +++++---------- src/Command/PolllingStartCommand.php | 15 +++++---------- src/Command/WebhookDeleteCommand.php | 15 +++++---------- src/Command/WebhookInfoCommand.php | 15 +++++---------- src/Command/WebhookUpdateCommand.php | 15 +++++---------- src/config/services.php | 12 ++++++------ 7 files changed, 36 insertions(+), 66 deletions(-) diff --git a/src/Command/ButtonDeleteCommand.php b/src/Command/ButtonDeleteCommand.php index 0285500..4826f51 100644 --- a/src/Command/ButtonDeleteCommand.php +++ b/src/Command/ButtonDeleteCommand.php @@ -8,11 +8,16 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; use Luzrain\TelegramBotApi\Type; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:button:delete', + 'Delete bot\'s menu button', +)] final class ButtonDeleteCommand extends Command { public function __construct( @@ -21,16 +26,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:button:delete'; - } - - public static function getDefaultDescription(): string - { - return 'Delete bot\'s mebu button'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/ButtonUpdateCommand.php b/src/Command/ButtonUpdateCommand.php index 83087f8..bf2df24 100644 --- a/src/Command/ButtonUpdateCommand.php +++ b/src/Command/ButtonUpdateCommand.php @@ -9,11 +9,16 @@ use Luzrain\TelegramBotApi\Method; use Luzrain\TelegramBotApi\Type; use Luzrain\TelegramBotBundle\CommandMetadataProvider; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:button:update', + 'Set published list of commands as as default bot\'s menu button', +)] final class ButtonUpdateCommand extends Command { private \Closure $descriptionProcessor; @@ -27,16 +32,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:button:update'; - } - - public static function getDefaultDescription(): string - { - return 'Set published list of commands as as default bot\'s mebu button'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/PolllingStartCommand.php b/src/Command/PolllingStartCommand.php index a1c168a..c9add47 100644 --- a/src/Command/PolllingStartCommand.php +++ b/src/Command/PolllingStartCommand.php @@ -8,12 +8,17 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotBundle\LongPollingService; use Luzrain\TelegramBotBundle\UpdateHandler; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:polling:start', + 'Run polling client to receive updates', +)] final class PolllingStartCommand extends Command { public function __construct( @@ -24,16 +29,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:polling:start'; - } - - public static function getDefaultDescription(): string - { - return 'Run polling client to receive updates'; - } - protected function configure(): void { $this->addOption('timeout', null, InputOption::VALUE_REQUIRED, 'Timeout for long polling connection in seconds', 15); diff --git a/src/Command/WebhookDeleteCommand.php b/src/Command/WebhookDeleteCommand.php index db09a99..6f5f5b2 100644 --- a/src/Command/WebhookDeleteCommand.php +++ b/src/Command/WebhookDeleteCommand.php @@ -7,11 +7,16 @@ use Luzrain\TelegramBotApi\BotApi; use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:webhook:delete', + 'Remove webhook integration', +)] final class WebhookDeleteCommand extends Command { public function __construct( @@ -20,16 +25,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:delete'; - } - - public static function getDefaultDescription(): string - { - return 'Remove webhook integration'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/WebhookInfoCommand.php b/src/Command/WebhookInfoCommand.php index 695ad6f..e4ba814 100644 --- a/src/Command/WebhookInfoCommand.php +++ b/src/Command/WebhookInfoCommand.php @@ -7,11 +7,16 @@ use Luzrain\TelegramBotApi\BotApi; use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:webhook:info', + 'Get current webhook status', +)] final class WebhookInfoCommand extends Command { public function __construct( @@ -20,16 +25,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:info'; - } - - public static function getDefaultDescription(): string - { - return 'Get current webhook status'; - } - protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/src/Command/WebhookUpdateCommand.php b/src/Command/WebhookUpdateCommand.php index f1f74a2..fefaa5c 100644 --- a/src/Command/WebhookUpdateCommand.php +++ b/src/Command/WebhookUpdateCommand.php @@ -8,12 +8,17 @@ use Luzrain\TelegramBotApi\Exception\TelegramApiException; use Luzrain\TelegramBotApi\Method\SetWebhook; use Luzrain\TelegramBotApi\Type\InputFile; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand( + 'telegram:webhook:update', + 'Update webhook settings', +)] final class WebhookUpdateCommand extends Command { public function __construct( @@ -28,16 +33,6 @@ public function __construct( parent::__construct(); } - public static function getDefaultName(): string - { - return 'telegram:webhook:update'; - } - - public static function getDefaultDescription(): string - { - return 'Update webhook settings'; - } - protected function configure(): void { $this->addOption('url', null, InputOption::VALUE_REQUIRED, 'Webhook url'); diff --git a/src/config/services.php b/src/config/services.php index 53a2b01..755b126 100644 --- a/src/config/services.php +++ b/src/config/services.php @@ -55,7 +55,7 @@ $container ->register('telegram_bot.webhook_update_command', WebhookUpdateCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference(BotApi::class), $config['allowed_updates'], @@ -68,19 +68,19 @@ $container ->register('telegram_bot.webhook_info_command', WebhookInfoCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ; $container ->register('telegram_bot.webhook_delete_command', WebhookDeleteCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ; $container ->register('telegram_bot.polling_start_command', PolllingStartCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference('telegram_bot.long_polling_service'), new Reference('telegram_bot.update_handler'), @@ -90,7 +90,7 @@ $container ->register('telegram_bot.button_update_commands', ButtonUpdateCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([ new Reference(BotApi::class), new Reference('telegram_bot.command_metadata_provider'), @@ -100,7 +100,7 @@ $container ->register('telegram_bot.button_delete_command', ButtonDeleteCommand::class) - ->addTag('console.command') + ->setAutoconfigured(true) ->setArguments([new Reference(BotApi::class)]) ; From 53d0e9a7d2b3c626a62dfe28b2b5e36b2dba3755 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 7 Nov 2025 23:44:58 +0800 Subject: [PATCH 2/2] Use named parameters --- src/Command/ButtonDeleteCommand.php | 4 ++-- src/Command/ButtonUpdateCommand.php | 4 ++-- src/Command/PolllingStartCommand.php | 4 ++-- src/Command/WebhookDeleteCommand.php | 4 ++-- src/Command/WebhookInfoCommand.php | 4 ++-- src/Command/WebhookUpdateCommand.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Command/ButtonDeleteCommand.php b/src/Command/ButtonDeleteCommand.php index 4826f51..e177b73 100644 --- a/src/Command/ButtonDeleteCommand.php +++ b/src/Command/ButtonDeleteCommand.php @@ -15,8 +15,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:button:delete', - 'Delete bot\'s menu button', + name: 'telegram:button:delete', + description: 'Delete bot\'s menu button', )] final class ButtonDeleteCommand extends Command { diff --git a/src/Command/ButtonUpdateCommand.php b/src/Command/ButtonUpdateCommand.php index bf2df24..02f6390 100644 --- a/src/Command/ButtonUpdateCommand.php +++ b/src/Command/ButtonUpdateCommand.php @@ -16,8 +16,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:button:update', - 'Set published list of commands as as default bot\'s menu button', + name: 'telegram:button:update', + description: 'Set published list of commands as as default bot\'s menu button', )] final class ButtonUpdateCommand extends Command { diff --git a/src/Command/PolllingStartCommand.php b/src/Command/PolllingStartCommand.php index c9add47..adae7f5 100644 --- a/src/Command/PolllingStartCommand.php +++ b/src/Command/PolllingStartCommand.php @@ -16,8 +16,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:polling:start', - 'Run polling client to receive updates', + name: 'telegram:polling:start', + description: 'Run polling client to receive updates', )] final class PolllingStartCommand extends Command { diff --git a/src/Command/WebhookDeleteCommand.php b/src/Command/WebhookDeleteCommand.php index 6f5f5b2..5b2d28f 100644 --- a/src/Command/WebhookDeleteCommand.php +++ b/src/Command/WebhookDeleteCommand.php @@ -14,8 +14,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:webhook:delete', - 'Remove webhook integration', + name: 'telegram:webhook:delete', + description: 'Remove webhook integration', )] final class WebhookDeleteCommand extends Command { diff --git a/src/Command/WebhookInfoCommand.php b/src/Command/WebhookInfoCommand.php index e4ba814..1d0436c 100644 --- a/src/Command/WebhookInfoCommand.php +++ b/src/Command/WebhookInfoCommand.php @@ -14,8 +14,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:webhook:info', - 'Get current webhook status', + name: 'telegram:webhook:info', + description: 'Get current webhook status', )] final class WebhookInfoCommand extends Command { diff --git a/src/Command/WebhookUpdateCommand.php b/src/Command/WebhookUpdateCommand.php index fefaa5c..e8fb960 100644 --- a/src/Command/WebhookUpdateCommand.php +++ b/src/Command/WebhookUpdateCommand.php @@ -16,8 +16,8 @@ use Symfony\Component\Console\Style\SymfonyStyle; #[AsCommand( - 'telegram:webhook:update', - 'Update webhook settings', + name: 'telegram:webhook:update', + description: 'Update webhook settings', )] final class WebhookUpdateCommand extends Command {