Skip to content

Commit

Permalink
Add support for Symfony 7 (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
morawskim authored Jan 10, 2024
1 parent 7f151c6 commit a80937c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Command/BaseConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
3 changes: 1 addition & 2 deletions Command/BaseRabbitMqCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Command/BatchConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion Command/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion Command/PurgeConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion Command/RpcServerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Command/StdInProducerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
21 changes: 21 additions & 0 deletions DependencyInjection/Compiler/ServiceContainerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace OldSound\RabbitMqBundle\DependencyInjection\Compiler;

use OldSound\RabbitMqBundle\Command\BaseRabbitMqCommand;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

class ServiceContainerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
foreach ($container->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')]);
}
}
}
}
2 changes: 2 additions & 0 deletions OldSoundRabbitMqBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

$container->addCompilerPass(new RegisterPartsPass());
$container->addCompilerPass(new InjectEventDispatcherPass());
$container->addCompilerPass(new ServiceContainerPass());
}

/**
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a80937c

Please sign in to comment.