Skip to content

Commit c8f3cef

Browse files
committed
feature #31785 [Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand's constructor (chalasr)
This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand's constructor | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Continuation of #31748 Commits ------- 1409338 [Messenger] Deprecate passing a bus locator to ConsumeMessagesCommand constructor
2 parents d775303 + 1409338 commit c8f3cef

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

UPGRADE-4.4.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UPGRADE FROM 4.3 to 4.4
44
HttpKernel
55
----------
66

7-
* The `DebugHandlersListener` class has been marked as `final`
7+
* The `DebugHandlersListener` class has been marked as `final`
88

99
DependencyInjection
1010
-------------------
@@ -25,13 +25,19 @@ DependencyInjection
2525
factory: ['@factory_service', method]
2626
```
2727
28+
Messenger
29+
---------
30+
31+
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
32+
pass a `RoutableMessageBus` instance instead.
33+
2834
MonologBridge
2935
--------------
3036

31-
* The `RouteProcessor` has been marked final.
37+
* The `RouteProcessor` has been marked final.
3238

3339
TwigBridge
3440
----------
3541

3642
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
37-
`DebugCommand::__construct()` method, swap the variables position.
43+
`DebugCommand::__construct()` method, swap the variables position.

UPGRADE-5.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ Messenger
269269
---------
270270

271271
* The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead.
272+
* Passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor now
273+
throws as `\TypeError`, pass a `RoutableMessageBus` instance instead.
272274

273275
Monolog
274276
-------

src/Symfony/Component/Messenger/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor,
8+
pass a `RoutableMessageBus` instance instead.
9+
410
4.3.0
511
-----
612

src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class ConsumeMessagesCommand extends Command
5454
*/
5555
public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* ContainerInterface */ $retryStrategyLocator = null, EventDispatcherInterface $eventDispatcher = null)
5656
{
57-
// to be deprecated in 4.4
5857
if ($routableBus instanceof ContainerInterface) {
58+
@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);
5959
$routableBus = new RoutableMessageBus($routableBus);
6060
}
6161

src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ConsumeMessagesCommandTest extends TestCase
2727
{
2828
public function testConfigurationWithDefaultReceiver()
2929
{
30-
$command = new ConsumeMessagesCommand($this->createMock(ServiceLocator::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
30+
$command = new ConsumeMessagesCommand($this->createMock(RoutableMessageBus::class), $this->createMock(ServiceLocator::class), null, ['amqp']);
3131
$inputArgument = $command->getDefinition()->getArgument('receivers');
3232
$this->assertFalse($inputArgument->isRequired());
3333
$this->assertSame(['amqp'], $inputArgument->getDefault());
@@ -98,6 +98,10 @@ public function testRunWithBusOption()
9898
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
9999
}
100100

101+
/**
102+
* @group legacy
103+
* @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.
104+
*/
101105
public function testBasicRunWithBusLocator()
102106
{
103107
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
@@ -130,6 +134,10 @@ public function testBasicRunWithBusLocator()
130134
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
131135
}
132136

137+
/**
138+
* @group legacy
139+
* @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.
140+
*/
133141
public function testRunWithBusOptionAndBusLocator()
134142
{
135143
$envelope = new Envelope(new \stdClass());

0 commit comments

Comments
 (0)
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