From 55179ca5358000324733973f55be709b9a370b13 Mon Sep 17 00:00:00 2001 From: viktorprogger Date: Sun, 26 Jan 2025 21:36:55 +0500 Subject: [PATCH] Allow usage of symfony/console version 7 --- composer.json | 2 +- src/Command/ListenAllCommand.php | 14 ++++++++------ src/Command/ListenCommand.php | 8 +++++--- src/Command/RunCommand.php | 9 +++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 601158d8..5109f74c 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "php": "^8.1", "psr/container": "^1.0|^2.0", "psr/log": "^2.0|^3.0", - "symfony/console": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0|^7.0", "yiisoft/definitions": "^3.3.1", "yiisoft/factory": "^1.3", "yiisoft/friendly-exception": "^1.0", diff --git a/src/Command/ListenAllCommand.php b/src/Command/ListenAllCommand.php index 8be6dead..da531ad1 100644 --- a/src/Command/ListenAllCommand.php +++ b/src/Command/ListenAllCommand.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -12,14 +13,15 @@ use Yiisoft\Queue\Cli\LoopInterface; use Yiisoft\Queue\Provider\QueueProviderInterface; +#[AsCommand( + 'queue:listen-all', + 'Listens the all the given queues and executes messages as they come. ' + . 'Meant to be used in development environment only. ' + . 'Listens all configured queues by default in case you\'re using yiisoft/config. ' + . 'Needs to be stopped manually.' +)] final class ListenAllCommand extends Command { - protected static $defaultName = 'queue:listen-all'; - protected static $defaultDescription = 'Listens the all the given queues and executes messages as they come. ' . - 'Meant to be used in development environment only. ' . - 'Listens all configured queues by default in case you\'re using yiisoft/config. ' . - 'Needs to be stopped manually.'; - public function __construct( private readonly QueueProviderInterface $queueProvider, private readonly LoopInterface $loop, diff --git a/src/Command/ListenCommand.php b/src/Command/ListenCommand.php index cfdbb329..3207385f 100644 --- a/src/Command/ListenCommand.php +++ b/src/Command/ListenCommand.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -11,11 +12,12 @@ use Yiisoft\Queue\Provider\QueueProviderInterface; use Yiisoft\Queue\QueueInterface; +#[AsCommand( + 'queue:listen', + 'Listens the queue and executes messages as they come. Needs to be stopped manually.' +)] final class ListenCommand extends Command { - protected static $defaultName = 'queue:listen'; - protected static $defaultDescription = 'Listens the queue and executes messages as they come. Needs to be stopped manually.'; - public function __construct( private readonly QueueProviderInterface $queueProvider ) { diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index a6bd3c18..65a450b8 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Command; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -11,12 +12,12 @@ use Symfony\Component\Console\Output\OutputInterface; use Yiisoft\Queue\Provider\QueueProviderInterface; +#[AsCommand( + 'queue:run', + 'Runs all the existing messages in the given queues. Exits once messages are over.' +)] final class RunCommand extends Command { - protected static $defaultName = 'queue:run'; - protected static $defaultDescription = 'Runs all the existing messages in the given queues. ' . - 'Exits once messages are over.'; - public function __construct( private readonly QueueProviderInterface $queueProvider, private readonly array $channels,