From 3509b9a62f3995b16d6e6bb2e85b630bc965726c Mon Sep 17 00:00:00 2001 From: Nikita Bolotov Date: Wed, 5 Jun 2024 11:31:54 +0300 Subject: [PATCH 1/5] fixed symfony 6.1 deprecation notices --- pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php | 2 +- pkg/enqueue/Symfony/Client/ConsumeCommand.php | 2 -- pkg/enqueue/Symfony/Client/ProduceCommand.php | 2 -- pkg/enqueue/Symfony/Client/RoutesCommand.php | 1 - pkg/enqueue/Symfony/Client/SetupBrokerCommand.php | 1 - pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php | 2 -- pkg/enqueue/Symfony/Consumption/ConsumeCommand.php | 2 -- 7 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php b/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php index 25016a761..0eb378470 100644 --- a/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php +++ b/pkg/enqueue/Doctrine/DoctrineSchemaCompilerPass.php @@ -11,7 +11,7 @@ class DoctrineSchemaCompilerPass implements CompilerPassInterface { - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (false === $container->hasDefinition('doctrine')) { return; diff --git a/pkg/enqueue/Symfony/Client/ConsumeCommand.php b/pkg/enqueue/Symfony/Client/ConsumeCommand.php index 39af6d592..c97dd3a33 100644 --- a/pkg/enqueue/Symfony/Client/ConsumeCommand.php +++ b/pkg/enqueue/Symfony/Client/ConsumeCommand.php @@ -28,8 +28,6 @@ class ConsumeCommand extends Command use QueueConsumerOptionsCommandTrait; use SetupBrokerExtensionCommandTrait; - protected static $defaultName = 'enqueue:consume'; - /** * @var ContainerInterface */ diff --git a/pkg/enqueue/Symfony/Client/ProduceCommand.php b/pkg/enqueue/Symfony/Client/ProduceCommand.php index 6064f82e1..512dd5f25 100644 --- a/pkg/enqueue/Symfony/Client/ProduceCommand.php +++ b/pkg/enqueue/Symfony/Client/ProduceCommand.php @@ -16,8 +16,6 @@ #[AsCommand('enqueue:produce')] class ProduceCommand extends Command { - protected static $defaultName = 'enqueue:produce'; - /** * @var ContainerInterface */ diff --git a/pkg/enqueue/Symfony/Client/RoutesCommand.php b/pkg/enqueue/Symfony/Client/RoutesCommand.php index 59a4a4d98..e0188e7da 100644 --- a/pkg/enqueue/Symfony/Client/RoutesCommand.php +++ b/pkg/enqueue/Symfony/Client/RoutesCommand.php @@ -17,7 +17,6 @@ #[AsCommand('enqueue:routes')] class RoutesCommand extends Command { - protected static $defaultName = 'enqueue:routes'; /** * @var ContainerInterface diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php index 68aebb582..326a58bff 100644 --- a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php +++ b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php @@ -15,7 +15,6 @@ #[AsCommand('enqueue:setup-broker')] class SetupBrokerCommand extends Command { - protected static $defaultName = 'enqueue:setup-broker'; /** * @var ContainerInterface diff --git a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php index 234eb0497..2847ca569 100644 --- a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php +++ b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php @@ -22,8 +22,6 @@ class ConfigurableConsumeCommand extends Command use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; - protected static $defaultName = 'enqueue:transport:consume'; - /** * @var ContainerInterface */ diff --git a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php index 870cc5f60..c8de790b8 100644 --- a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php +++ b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php @@ -20,8 +20,6 @@ class ConsumeCommand extends Command use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; - protected static $defaultName = 'enqueue:transport:consume'; - /** * @var ContainerInterface */ From 3f91a6671713e2700dec5adee917ed3829a93d62 Mon Sep 17 00:00:00 2001 From: Nikita Bolotov Date: Wed, 5 Jun 2024 11:39:50 +0300 Subject: [PATCH 2/5] fixed symfony 6.1 deprecation notices --- pkg/enqueue/Symfony/Client/RoutesCommand.php | 1 - pkg/enqueue/Symfony/Client/SetupBrokerCommand.php | 1 - 2 files changed, 2 deletions(-) diff --git a/pkg/enqueue/Symfony/Client/RoutesCommand.php b/pkg/enqueue/Symfony/Client/RoutesCommand.php index e0188e7da..99979d5c1 100644 --- a/pkg/enqueue/Symfony/Client/RoutesCommand.php +++ b/pkg/enqueue/Symfony/Client/RoutesCommand.php @@ -17,7 +17,6 @@ #[AsCommand('enqueue:routes')] class RoutesCommand extends Command { - /** * @var ContainerInterface */ diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php index 326a58bff..78bb4041d 100644 --- a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php +++ b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php @@ -15,7 +15,6 @@ #[AsCommand('enqueue:setup-broker')] class SetupBrokerCommand extends Command { - /** * @var ContainerInterface */ From 3be1369f2c8c10d6a07c8596354f849827fe1514 Mon Sep 17 00:00:00 2001 From: Nikita Bolotov Date: Fri, 7 Jun 2024 16:50:22 +0300 Subject: [PATCH 3/5] fixed BC --- pkg/enqueue/Symfony/Client/ConsumeCommand.php | 6 ++++-- pkg/enqueue/Symfony/Client/ProduceCommand.php | 6 ++++-- pkg/enqueue/Symfony/Client/RoutesCommand.php | 5 +++-- pkg/enqueue/Symfony/Client/SetupBrokerCommand.php | 6 ++++-- .../Symfony/Consumption/ConfigurableConsumeCommand.php | 6 ++++-- pkg/enqueue/Symfony/Consumption/ConsumeCommand.php | 6 ++++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pkg/enqueue/Symfony/Client/ConsumeCommand.php b/pkg/enqueue/Symfony/Client/ConsumeCommand.php index c97dd3a33..cdf8a8c9c 100644 --- a/pkg/enqueue/Symfony/Client/ConsumeCommand.php +++ b/pkg/enqueue/Symfony/Client/ConsumeCommand.php @@ -20,7 +20,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:consume')] +#[AsCommand(self::COMMAND_NAME)] class ConsumeCommand extends Command { use ChooseLoggerCommandTrait; @@ -28,6 +28,8 @@ class ConsumeCommand extends Command use QueueConsumerOptionsCommandTrait; use SetupBrokerExtensionCommandTrait; + private const COMMAND_NAME = 'enqueue:consume'; + /** * @var ContainerInterface */ @@ -66,7 +68,7 @@ public function __construct( $this->driverIdPattern = $driverIdPattern; $this->processorIdPattern = $processorIdPatter; - parent::__construct(self::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void diff --git a/pkg/enqueue/Symfony/Client/ProduceCommand.php b/pkg/enqueue/Symfony/Client/ProduceCommand.php index 512dd5f25..e5215cd6f 100644 --- a/pkg/enqueue/Symfony/Client/ProduceCommand.php +++ b/pkg/enqueue/Symfony/Client/ProduceCommand.php @@ -13,9 +13,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:produce')] +#[AsCommand(self::COMMAND_NAME)] class ProduceCommand extends Command { + private const COMMAND_NAME = 'enqueue:produce'; + /** * @var ContainerInterface */ @@ -37,7 +39,7 @@ public function __construct(ContainerInterface $container, string $defaultClient $this->defaultClient = $defaultClient; $this->producerIdPattern = $producerIdPattern; - parent::__construct(static::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void diff --git a/pkg/enqueue/Symfony/Client/RoutesCommand.php b/pkg/enqueue/Symfony/Client/RoutesCommand.php index 99979d5c1..542633933 100644 --- a/pkg/enqueue/Symfony/Client/RoutesCommand.php +++ b/pkg/enqueue/Symfony/Client/RoutesCommand.php @@ -14,9 +14,10 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:routes')] +#[AsCommand(self::COMMAND_NAME)] class RoutesCommand extends Command { + private const COMMAND_NAME = 'enqueue:routes'; /** * @var ContainerInterface */ @@ -43,7 +44,7 @@ public function __construct(ContainerInterface $container, string $defaultClient $this->defaultClient = $defaultClient; $this->driverIdPatter = $driverIdPatter; - parent::__construct(static::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void diff --git a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php index 78bb4041d..b23420715 100644 --- a/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php +++ b/pkg/enqueue/Symfony/Client/SetupBrokerCommand.php @@ -12,9 +12,11 @@ use Symfony\Component\Console\Logger\ConsoleLogger; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:setup-broker')] +#[AsCommand(self::COMMAND_NAME)] class SetupBrokerCommand extends Command { + private const COMMAND_NAME = 'enqueue:setup-broker'; + /** * @var ContainerInterface */ @@ -36,7 +38,7 @@ public function __construct(ContainerInterface $container, string $defaultClient $this->defaultClient = $defaultClient; $this->driverIdPattern = $driverIdPattern; - parent::__construct(static::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void diff --git a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php index 2847ca569..3dc648799 100644 --- a/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php +++ b/pkg/enqueue/Symfony/Consumption/ConfigurableConsumeCommand.php @@ -15,13 +15,15 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:transport:consume')] +#[AsCommand(self::COMMAND_NAME)] class ConfigurableConsumeCommand extends Command { use ChooseLoggerCommandTrait; use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; + private const COMMAND_NAME = 'enqueue:transport:consume'; + /** * @var ContainerInterface */ @@ -53,7 +55,7 @@ public function __construct( $this->queueConsumerIdPattern = $queueConsumerIdPattern; $this->processorRegistryIdPattern = $processorRegistryIdPattern; - parent::__construct(static::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void diff --git a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php index c8de790b8..008982ff3 100644 --- a/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php +++ b/pkg/enqueue/Symfony/Consumption/ConsumeCommand.php @@ -13,13 +13,15 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('enqueue:transport:consume')] +#[AsCommand(self::COMMAND_NAME)] class ConsumeCommand extends Command { use ChooseLoggerCommandTrait; use LimitsExtensionsCommandTrait; use QueueConsumerOptionsCommandTrait; + private const COMMAND_NAME = 'enqueue:transport:consume'; + /** * @var ContainerInterface */ @@ -41,7 +43,7 @@ public function __construct(ContainerInterface $container, string $defaultTransp $this->defaultTransport = $defaultTransport; $this->queueConsumerIdPattern = $queueConsumerIdPattern; - parent::__construct(static::$defaultName); + parent::__construct(self::COMMAND_NAME); } protected function configure(): void From 12a897499e5c45a81677432167f6918c9c1713cf Mon Sep 17 00:00:00 2001 From: Nikita Bolotov Date: Fri, 7 Jun 2024 17:15:42 +0300 Subject: [PATCH 4/5] MessageQueueCollector return type --- pkg/enqueue-bundle/Profiler/MessageQueueCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php index 7fc6699c5..d11b221ee 100644 --- a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php +++ b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php @@ -8,7 +8,7 @@ class MessageQueueCollector extends AbstractMessageQueueCollector { - public function collect(Request $request, Response $response, Throwable $exception = null) + public function collect(Request $request, Response $response, Throwable $exception = null): void { $this->collectInternal($request, $response); } From ee0ab0bc80b38af560aedfc7ff8039760ac493b9 Mon Sep 17 00:00:00 2001 From: Nikita Bolotov Date: Tue, 11 Jun 2024 18:39:23 +0300 Subject: [PATCH 5/5] fixed unit tests & code style --- composer.json | 4 ++-- pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php | 6 ++++-- pkg/enqueue-bundle/Profiler/MessageQueueCollector.php | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 5c0108e27..d1a22b039 100644 --- a/composer.json +++ b/composer.json @@ -72,7 +72,8 @@ "kwn/php-rdkafka-stubs": "^2.0.3", "friendsofphp/php-cs-fixer": "^3.4", "dms/phpunit-arraysubset-asserts": "^0.2.1", - "phpspec/prophecy-phpunit": "^2.0" + "phpspec/prophecy-phpunit": "^2.0", + "symfony/http-foundation": "^5.4|^6.0" }, "autoload": { "psr-4": { @@ -137,4 +138,3 @@ } } } - diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index a90b1d306..0a74f1e2b 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -158,10 +158,11 @@ public function testConsumerReceiveMessageFromTopicDirectly() $this->amqpContext->declareTopic($topic); $consumer = $this->amqpContext->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->amqpContext->createMessage(__METHOD__); + $message->setDeliveryTag(1); $producer = $this->amqpContext->createProducer(); $producer->send($topic, $message); @@ -181,10 +182,11 @@ public function testConsumerReceiveMessageWithZeroTimeout() $this->amqpContext->declareTopic($topic); $consumer = $this->amqpContext->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->amqpContext->createMessage(__METHOD__); + $message->setDeliveryTag(1); $producer = $this->amqpContext->createProducer(); $producer->send($topic, $message); diff --git a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php index d11b221ee..3c484a7d1 100644 --- a/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php +++ b/pkg/enqueue-bundle/Profiler/MessageQueueCollector.php @@ -4,11 +4,10 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Throwable; class MessageQueueCollector extends AbstractMessageQueueCollector { - public function collect(Request $request, Response $response, Throwable $exception = null): void + public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { $this->collectInternal($request, $response); }