From 14093386e6e28fb399e53ef4d9392a4fa04d4cfd Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 1 Jun 2019 14:56:25 +0200 Subject: [PATCH] [Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand constructor --- UPGRADE-4.4.md | 12 +++++++++--- UPGRADE-5.0.md | 2 ++ src/Symfony/Component/Messenger/CHANGELOG.md | 6 ++++++ .../Messenger/Command/ConsumeMessagesCommand.php | 2 +- .../Tests/Command/ConsumeMessagesCommandTest.php | 10 +++++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index e9cee836e78d7..0e044861bd3c2 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -4,7 +4,7 @@ UPGRADE FROM 4.3 to 4.4 HttpKernel ---------- -* The `DebugHandlersListener` class has been marked as `final` + * The `DebugHandlersListener` class has been marked as `final` DependencyInjection ------------------- @@ -25,13 +25,19 @@ DependencyInjection factory: ['@factory_service', method] ``` +Messenger +--------- + + * Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor, + pass a `RoutableMessageBus` instance instead. + MonologBridge -------------- -* The `RouteProcessor` has been marked final. + * The `RouteProcessor` has been marked final. TwigBridge ---------- * Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the - `DebugCommand::__construct()` method, swap the variables position. \ No newline at end of file + `DebugCommand::__construct()` method, swap the variables position. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 49ccf3aa0bd2c..289910e8c2daa 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -269,6 +269,8 @@ Messenger --------- * The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead. + * Passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor now + throws as `\TypeError`, pass a `RoutableMessageBus` instance instead. Monolog ------- diff --git a/src/Symfony/Component/Messenger/CHANGELOG.md b/src/Symfony/Component/Messenger/CHANGELOG.md index 49d04feb1f276..fc01fa52ccff2 100644 --- a/src/Symfony/Component/Messenger/CHANGELOG.md +++ b/src/Symfony/Component/Messenger/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +4.4.0 +----- + + * Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor, + pass a `RoutableMessageBus` instance instead. + 4.3.0 ----- diff --git a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php index be6f4c1733b27..816cd30c3562b 100644 --- a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php @@ -54,8 +54,8 @@ class ConsumeMessagesCommand extends Command */ public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null) { - // to be deprecated in 4.4 if ($routableBus instanceof ContainerInterface) { + @trigger_error(sprintf('Passing a "%s" instance as first argument to "%s()" is deprecated since Symfony 4.4, pass a "%s" instance instead.', ContainerInterface::class, __METHOD__, RoutableMessageBus::class), E_USER_DEPRECATED); $routableBus = new RoutableMessageBus($routableBus); } diff --git a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php index 3191c65b644a4..c7ae75cc1b428 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php @@ -27,7 +27,7 @@ class ConsumeMessagesCommandTest extends TestCase { public function testConfigurationWithDefaultReceiver() { - $command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp']); + $command = new ConsumeMessagesCommand($this->createMock(RoutableMessageBus::class), $this->createMock(ServiceLocator::class), null, ['amqp']); $inputArgument = $command->getDefinition()->getArgument('receivers'); $this->assertFalse($inputArgument->isRequired()); $this->assertSame(['amqp'], $inputArgument->getDefault()); @@ -98,6 +98,10 @@ public function testRunWithBusOption() $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); } + /** + * @group legacy + * @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead. + */ public function testBasicRunWithBusLocator() { $envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]); @@ -130,6 +134,10 @@ public function testBasicRunWithBusLocator() $this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay()); } + /** + * @group legacy + * @expectedDeprecation Passing a "Psr\Container\ContainerInterface" instance as first argument to "Symfony\Component\Messenger\Command\ConsumeMessagesCommand::__construct()" is deprecated since Symfony 4.4, pass a "Symfony\Component\Messenger\RoutableMessageBus" instance instead. + */ public function testRunWithBusOptionAndBusLocator() { $envelope = new Envelope(new \stdClass()); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy