Skip to content

Commit db92f1c

Browse files
committed
Rename test action to avoid AbstractController::dispatchMessage collision
Symfony 5.4 and 6.4 ship AbstractController::dispatchMessage(object $message, array $stamps = []): Envelope. The Messenger test action declared an incompatible override (dispatchMessage(MessageBusInterface): Response), which is fatal on those versions and only passed locally because newer Symfony dropped that parent method. Rename the action to dispatchTestMessage; the route is unchanged (/dispatch-message).
1 parent d724613 commit db92f1c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/_app/Controller/AppController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ public function dispatchEvent(EventDispatcherInterface $dispatcher): Response
5454
return new Response('Event dispatched');
5555
}
5656

57-
public function dispatchMessage(MessageBusInterface $bus): Response
58-
{
59-
$bus->dispatch(new TestMessage('Hello from Messenger'));
60-
61-
return new Response('Message dispatched');
62-
}
63-
6457
public function dispatchNamedEvent(EventDispatcherInterface $dispatcher): Response
6558
{
6659
$dispatcher->dispatch(new TestEvent(), 'named.event');
@@ -75,6 +68,13 @@ public function dispatchOrphanEvent(EventDispatcherInterface $dispatcher): Respo
7568
return new Response('Orphan event dispatched');
7669
}
7770

71+
public function dispatchTestMessage(MessageBusInterface $bus): Response
72+
{
73+
$bus->dispatch(new TestMessage('Hello from Messenger'));
74+
75+
return new Response('Message dispatched');
76+
}
77+
7878
public function form(Request $request, FormFactoryInterface $formFactory, Environment $twig): Response
7979
{
8080
$builder = $formFactory->createNamedBuilder('registration_form', options: ['csrf_protection' => false]);

tests/_app/config/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$routes->add('dashboard', '/dashboard')->controller(AppController::class . '::dashboard');
1212
$routes->add('deprecated', '/deprecated')->controller(AppController::class . '::deprecated');
1313
$routes->add('dispatch_event', '/dispatch-event')->controller(AppController::class . '::dispatchEvent');
14-
$routes->add('dispatch_message', '/dispatch-message')->controller(AppController::class . '::dispatchMessage');
14+
$routes->add('dispatch_message', '/dispatch-message')->controller(AppController::class . '::dispatchTestMessage');
1515
$routes->add('dispatch_named_event', '/dispatch-named-event')->controller(AppController::class . '::dispatchNamedEvent');
1616
$routes->add('dispatch_orphan_event', '/dispatch-orphan-event')->controller(AppController::class . '::dispatchOrphanEvent');
1717
$routes->add('form_handler', '/form')->controller(AppController::class . '::form');

0 commit comments

Comments
 (0)