diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 16ff831b..c4b62f77 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,11 +16,13 @@ jobs: strategy: matrix: php-version: ['7.4', '8.2'] - symfony-version: ['4.4', '5.3', '5.4', '6.0'] + symfony-version: ['4.4', '5.3', '5.4', '6.4', '7.0'] coverage: ['none'] exclude: - php-version: '7.4' - symfony-version: '6.0' + symfony-version: '6.4' + - php-version: '7.4' + symfony-version: '7.0' include: - php-version: '8.0' symfony-version: '5.4' diff --git a/Command/BaseConsumerCommand.php b/Command/BaseConsumerCommand.php index 2d8066ab..ff1c8039 100644 --- a/Command/BaseConsumerCommand.php +++ b/Command/BaseConsumerCommand.php @@ -70,7 +70,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v * @throws \InvalidArgumentException When the number of messages to consume is less than 0 * @throws \BadFunctionCallException When the pcntl is not installed and option -s is true */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if (defined('AMQP_WITHOUT_SIGNALS') === false) { define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals')); diff --git a/Command/BaseRabbitMqCommand.php b/Command/BaseRabbitMqCommand.php index 03882235..c4ae61eb 100644 --- a/Command/BaseRabbitMqCommand.php +++ b/Command/BaseRabbitMqCommand.php @@ -2,11 +2,10 @@ namespace OldSound\RabbitMqBundle\Command; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Console\Command\Command; -abstract class BaseRabbitMqCommand extends Command implements ContainerAwareInterface +abstract class BaseRabbitMqCommand extends Command { /** * @var ContainerInterface diff --git a/Command/BatchConsumerCommand.php b/Command/BatchConsumerCommand.php index c849657b..46bd1571 100644 --- a/Command/BatchConsumerCommand.php +++ b/Command/BatchConsumerCommand.php @@ -56,7 +56,7 @@ protected function configure(): void * @throws \InvalidArgumentException When the number of batches to consume is less than 0 * @throws \BadFunctionCallException When the pcntl is not installed and option -s is true */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if (defined('AMQP_WITHOUT_SIGNALS') === false) { define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals')); diff --git a/Command/DeleteCommand.php b/Command/DeleteCommand.php index b358bf60..c67ad33d 100644 --- a/Command/DeleteCommand.php +++ b/Command/DeleteCommand.php @@ -33,7 +33,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $noConfirmation = (bool) $input->getOption('no-confirmation'); diff --git a/Command/PurgeConsumerCommand.php b/Command/PurgeConsumerCommand.php index f0eabf5b..7401afde 100644 --- a/Command/PurgeConsumerCommand.php +++ b/Command/PurgeConsumerCommand.php @@ -33,7 +33,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v * * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $noConfirmation = (bool) $input->getOption('no-confirmation'); diff --git a/Command/RpcServerCommand.php b/Command/RpcServerCommand.php index a4db3629..e52f9af8 100644 --- a/Command/RpcServerCommand.php +++ b/Command/RpcServerCommand.php @@ -32,7 +32,7 @@ protected function configure(): void * * @throws \InvalidArgumentException When the number of messages to consume is less than 0 */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { define('AMQP_DEBUG', (bool) $input->getOption('debug')); $amount = (int)$input->getOption('messages'); diff --git a/Command/StdInProducerCommand.php b/Command/StdInProducerCommand.php index b77f611b..5db949f5 100644 --- a/Command/StdInProducerCommand.php +++ b/Command/StdInProducerCommand.php @@ -34,7 +34,7 @@ protected function configure(): void * * @return integer 0 if everything went fine, or an error code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { define('AMQP_DEBUG', (bool) $input->getOption('debug')); diff --git a/DependencyInjection/Compiler/ServiceContainerPass.php b/DependencyInjection/Compiler/ServiceContainerPass.php new file mode 100644 index 00000000..551230d3 --- /dev/null +++ b/DependencyInjection/Compiler/ServiceContainerPass.php @@ -0,0 +1,21 @@ +findTaggedServiceIds('console.command') as $id => $attributes) { + $command = $container->findDefinition($id); + if (is_a($command->getClass(), BaseRabbitMqCommand::class, true)) { + $command->addMethodCall('setContainer', [new Reference('service_container')]); + } + } + } +} diff --git a/OldSoundRabbitMqBundle.php b/OldSoundRabbitMqBundle.php index 8ed4223f..4d2e0ffd 100644 --- a/OldSoundRabbitMqBundle.php +++ b/OldSoundRabbitMqBundle.php @@ -4,6 +4,7 @@ use OldSound\RabbitMqBundle\DependencyInjection\Compiler\InjectEventDispatcherPass; use OldSound\RabbitMqBundle\DependencyInjection\Compiler\RegisterPartsPass; +use OldSound\RabbitMqBundle\DependencyInjection\Compiler\ServiceContainerPass; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -15,6 +16,7 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new RegisterPartsPass()); $container->addCompilerPass(new InjectEventDispatcherPass()); + $container->addCompilerPass(new ServiceContainerPass()); } /** diff --git a/composer.json b/composer.json index f66ffdb2..58511207 100644 --- a/composer.json +++ b/composer.json @@ -10,18 +10,18 @@ "require": { "php": "^7.4|^8.0", - "symfony/dependency-injection": "^4.4|^5.3|^6.0", - "symfony/event-dispatcher": "^4.4|^5.3|^6.0", - "symfony/config": "^4.4|^5.3|^6.0", - "symfony/yaml": "^4.4|^5.3|^6.0", - "symfony/console": "^4.4|^5.3|^6.0", + "symfony/dependency-injection": "^4.4|^5.3|^6.0|^7.0", + "symfony/event-dispatcher": "^4.4|^5.3|^6.0|^7.0", + "symfony/config": "^4.4|^5.3|^6.0|^7.0", + "symfony/yaml": "^4.4|^5.3|^6.0|^7.0", + "symfony/console": "^4.4|^5.3|^6.0|^7.0", "php-amqplib/php-amqplib": "^2.12.2|^3.0", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/http-kernel": "^4.4|^5.3|^6.0", - "symfony/framework-bundle": "^4.4|^5.3|^6.0" + "symfony/http-kernel": "^4.4|^5.3|^6.0|^7.0", + "symfony/framework-bundle": "^4.4|^5.3|^6.0|^7.0" }, "require-dev": { - "symfony/serializer": "^4.4|^5.3|^6.0", + "symfony/serializer": "^4.4|^5.3|^6.0|^7.0", "phpunit/phpunit": "^9.5", "phpstan/phpstan": "^1.2", "phpstan/phpstan-phpunit": "^1.0"