Skip to content

Commit a80937c

Browse files
authored
Add support for Symfony 7 (#721)
1 parent 7f151c6 commit a80937c

11 files changed

+42
-18
lines changed

.github/workflows/test.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ jobs:
1616
strategy:
1717
matrix:
1818
php-version: ['7.4', '8.2']
19-
symfony-version: ['4.4', '5.3', '5.4', '6.0']
19+
symfony-version: ['4.4', '5.3', '5.4', '6.4', '7.0']
2020
coverage: ['none']
2121
exclude:
2222
- php-version: '7.4'
23-
symfony-version: '6.0'
23+
symfony-version: '6.4'
24+
- php-version: '7.4'
25+
symfony-version: '7.0'
2426
include:
2527
- php-version: '8.0'
2628
symfony-version: '5.4'

Command/BaseConsumerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
7070
* @throws \InvalidArgumentException When the number of messages to consume is less than 0
7171
* @throws \BadFunctionCallException When the pcntl is not installed and option -s is true
7272
*/
73-
protected function execute(InputInterface $input, OutputInterface $output)
73+
protected function execute(InputInterface $input, OutputInterface $output): int
7474
{
7575
if (defined('AMQP_WITHOUT_SIGNALS') === false) {
7676
define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals'));

Command/BaseRabbitMqCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace OldSound\RabbitMqBundle\Command;
44

5-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
65
use Symfony\Component\DependencyInjection\ContainerInterface;
76
use Symfony\Component\Console\Command\Command;
87

9-
abstract class BaseRabbitMqCommand extends Command implements ContainerAwareInterface
8+
abstract class BaseRabbitMqCommand extends Command
109
{
1110
/**
1211
* @var ContainerInterface

Command/BatchConsumerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function configure(): void
5656
* @throws \InvalidArgumentException When the number of batches to consume is less than 0
5757
* @throws \BadFunctionCallException When the pcntl is not installed and option -s is true
5858
*/
59-
protected function execute(InputInterface $input, OutputInterface $output)
59+
protected function execute(InputInterface $input, OutputInterface $output): int
6060
{
6161
if (defined('AMQP_WITHOUT_SIGNALS') === false) {
6262
define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals'));

Command/DeleteCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
3333
*
3434
* @return int
3535
*/
36-
protected function execute(InputInterface $input, OutputInterface $output)
36+
protected function execute(InputInterface $input, OutputInterface $output): int
3737
{
3838
$noConfirmation = (bool) $input->getOption('no-confirmation');
3939

Command/PurgeConsumerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
3333
*
3434
* @return int
3535
*/
36-
protected function execute(InputInterface $input, OutputInterface $output)
36+
protected function execute(InputInterface $input, OutputInterface $output): int
3737
{
3838
$noConfirmation = (bool) $input->getOption('no-confirmation');
3939

Command/RpcServerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function configure(): void
3232
*
3333
* @throws \InvalidArgumentException When the number of messages to consume is less than 0
3434
*/
35-
protected function execute(InputInterface $input, OutputInterface $output)
35+
protected function execute(InputInterface $input, OutputInterface $output): int
3636
{
3737
define('AMQP_DEBUG', (bool) $input->getOption('debug'));
3838
$amount = (int)$input->getOption('messages');

Command/StdInProducerCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function configure(): void
3434
*
3535
* @return integer 0 if everything went fine, or an error code
3636
*/
37-
protected function execute(InputInterface $input, OutputInterface $output)
37+
protected function execute(InputInterface $input, OutputInterface $output): int
3838
{
3939
define('AMQP_DEBUG', (bool) $input->getOption('debug'));
4040

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace OldSound\RabbitMqBundle\DependencyInjection\Compiler;
4+
5+
use OldSound\RabbitMqBundle\Command\BaseRabbitMqCommand;
6+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
use Symfony\Component\DependencyInjection\Reference;
9+
10+
class ServiceContainerPass implements CompilerPassInterface
11+
{
12+
public function process(ContainerBuilder $container): void
13+
{
14+
foreach ($container->findTaggedServiceIds('console.command') as $id => $attributes) {
15+
$command = $container->findDefinition($id);
16+
if (is_a($command->getClass(), BaseRabbitMqCommand::class, true)) {
17+
$command->addMethodCall('setContainer', [new Reference('service_container')]);
18+
}
19+
}
20+
}
21+
}

OldSoundRabbitMqBundle.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\InjectEventDispatcherPass;
66
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\RegisterPartsPass;
7+
use OldSound\RabbitMqBundle\DependencyInjection\Compiler\ServiceContainerPass;
78
use Symfony\Component\HttpKernel\Bundle\Bundle;
89
use Symfony\Component\DependencyInjection\ContainerBuilder;
910

@@ -15,6 +16,7 @@ public function build(ContainerBuilder $container): void
1516

1617
$container->addCompilerPass(new RegisterPartsPass());
1718
$container->addCompilerPass(new InjectEventDispatcherPass());
19+
$container->addCompilerPass(new ServiceContainerPass());
1820
}
1921

2022
/**

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
"require": {
1111
"php": "^7.4|^8.0",
1212

13-
"symfony/dependency-injection": "^4.4|^5.3|^6.0",
14-
"symfony/event-dispatcher": "^4.4|^5.3|^6.0",
15-
"symfony/config": "^4.4|^5.3|^6.0",
16-
"symfony/yaml": "^4.4|^5.3|^6.0",
17-
"symfony/console": "^4.4|^5.3|^6.0",
13+
"symfony/dependency-injection": "^4.4|^5.3|^6.0|^7.0",
14+
"symfony/event-dispatcher": "^4.4|^5.3|^6.0|^7.0",
15+
"symfony/config": "^4.4|^5.3|^6.0|^7.0",
16+
"symfony/yaml": "^4.4|^5.3|^6.0|^7.0",
17+
"symfony/console": "^4.4|^5.3|^6.0|^7.0",
1818
"php-amqplib/php-amqplib": "^2.12.2|^3.0",
1919
"psr/log": "^1.0 || ^2.0 || ^3.0",
20-
"symfony/http-kernel": "^4.4|^5.3|^6.0",
21-
"symfony/framework-bundle": "^4.4|^5.3|^6.0"
20+
"symfony/http-kernel": "^4.4|^5.3|^6.0|^7.0",
21+
"symfony/framework-bundle": "^4.4|^5.3|^6.0|^7.0"
2222
},
2323
"require-dev": {
24-
"symfony/serializer": "^4.4|^5.3|^6.0",
24+
"symfony/serializer": "^4.4|^5.3|^6.0|^7.0",
2525
"phpunit/phpunit": "^9.5",
2626
"phpstan/phpstan": "^1.2",
2727
"phpstan/phpstan-phpunit": "^1.0"

0 commit comments

Comments
 (0)