From 4b3c6e98215cbc67c79fe0bfb6af55ccaac0e8fe Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 16 Aug 2023 18:31:45 +0200 Subject: [PATCH] Use `#[AsCommand]` attribute on commands Fixes the following deprecations: ```json { "message": "Since symfony/console 6.1: Relying on the static property \"$defaultName\" for setting a command name is deprecated. Add the \"Symfony\\Component\\Console\\Attribute\\AsCommand\" attribute to the \"Enqueue\\Symfony\\Consumption\\ConfigurableConsumeCommand\" class instead.", "count": 1 }, { "message": "Since symfony/console 6.1: Relying on the static property \"$defaultName\" for setting a command name is deprecated. Add the \"Symfony\\Component\\Console\\Attribute\\AsCommand\" attribute to the \"Enqueue\\Symfony\\Client\\ConsumeCommand\" class instead.", "count": 1 }, { "message": "Since symfony/console 6.1: Relying on the static property \"$defaultName\" for setting a command name is deprecated. Add the \"Symfony\\Component\\Console\\Attribute\\AsCommand\" attribute to the \"Enqueue\\Symfony\\Client\\ProduceCommand\" class instead.", "count": 1 }, { "message": "Since symfony/console 6.1: Relying on the static property \"$defaultName\" for setting a command name is deprecated. Add the \"Symfony\\Component\\Console\\Attribute\\AsCommand\" attribute to the \"Enqueue\\Symfony\\Client\\SetupBrokerCommand\" class instead.", "count": 1 }, { "message": "Since symfony/console 6.1: Relying on the static property \"$defaultName\" for setting a command name is deprecated. Add the \"Symfony\\Component\\Console\\Attribute\\AsCommand\" attribute to the \"Enqueue\\Symfony\\Client\\RoutesCommand\" class instead.", "count": 1 }, ``` --- Symfony/Client/ConsumeCommand.php | 6 ++++-- Symfony/Client/ProduceCommand.php | 2 ++ Symfony/Client/RoutesCommand.php | 2 ++ Symfony/Client/SetupBrokerCommand.php | 2 ++ Symfony/Consumption/ConfigurableConsumeCommand.php | 4 +++- Symfony/Consumption/ConsumeCommand.php | 4 +++- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Symfony/Client/ConsumeCommand.php b/Symfony/Client/ConsumeCommand.php index 4b65f62..39af6d5 100644 --- a/Symfony/Client/ConsumeCommand.php +++ b/Symfony/Client/ConsumeCommand.php @@ -13,18 +13,20 @@ use Interop\Queue\Processor; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand('enqueue:consume')] class ConsumeCommand extends Command { + use ChooseLoggerCommandTrait; use LimitsExtensionsCommandTrait; - use SetupBrokerExtensionCommandTrait; use QueueConsumerOptionsCommandTrait; - use ChooseLoggerCommandTrait; + use SetupBrokerExtensionCommandTrait; protected static $defaultName = 'enqueue:consume'; diff --git a/Symfony/Client/ProduceCommand.php b/Symfony/Client/ProduceCommand.php index 667871c..6064f82 100644 --- a/Symfony/Client/ProduceCommand.php +++ b/Symfony/Client/ProduceCommand.php @@ -6,12 +6,14 @@ use Enqueue\Client\ProducerInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand('enqueue:produce')] class ProduceCommand extends Command { protected static $defaultName = 'enqueue:produce'; diff --git a/Symfony/Client/RoutesCommand.php b/Symfony/Client/RoutesCommand.php index 5419f3b..59a4a4d 100644 --- a/Symfony/Client/RoutesCommand.php +++ b/Symfony/Client/RoutesCommand.php @@ -6,6 +6,7 @@ use Enqueue\Client\Route; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableSeparator; @@ -13,6 +14,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand('enqueue:routes')] class RoutesCommand extends Command { protected static $defaultName = 'enqueue:routes'; diff --git a/Symfony/Client/SetupBrokerCommand.php b/Symfony/Client/SetupBrokerCommand.php index 65d52ee..68aebb5 100644 --- a/Symfony/Client/SetupBrokerCommand.php +++ b/Symfony/Client/SetupBrokerCommand.php @@ -5,12 +5,14 @@ use Enqueue\Client\DriverInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +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\Logger\ConsoleLogger; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand('enqueue:setup-broker')] class SetupBrokerCommand extends Command { protected static $defaultName = 'enqueue:setup-broker'; diff --git a/Symfony/Consumption/ConfigurableConsumeCommand.php b/Symfony/Consumption/ConfigurableConsumeCommand.php index 9ec8a36..234eb04 100644 --- a/Symfony/Consumption/ConfigurableConsumeCommand.php +++ b/Symfony/Consumption/ConfigurableConsumeCommand.php @@ -8,17 +8,19 @@ use Enqueue\ProcessorRegistryInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand('enqueue:transport:consume')] class ConfigurableConsumeCommand extends Command { + use ChooseLoggerCommandTrait; use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; - use ChooseLoggerCommandTrait; protected static $defaultName = 'enqueue:transport:consume'; diff --git a/Symfony/Consumption/ConsumeCommand.php b/Symfony/Consumption/ConsumeCommand.php index b1a54c1..870cc5f 100644 --- a/Symfony/Consumption/ConsumeCommand.php +++ b/Symfony/Consumption/ConsumeCommand.php @@ -7,16 +7,18 @@ use Enqueue\Consumption\QueueConsumerInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; +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; +#[AsCommand('enqueue:transport:consume')] class ConsumeCommand extends Command { + use ChooseLoggerCommandTrait; use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; - use ChooseLoggerCommandTrait; protected static $defaultName = 'enqueue:transport:consume';