Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Open
Description
I found a severe pitfall in this example code:
symfony-docs/event_dispatcher.rst
Lines 198 to 208 inb9f8400
:class:`Symfony\\Component\\EventDispatcher\\Attribute\\AsEventListener` | |
can also be applied to methods directly:: | |
namespace App\EventListener; | |
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | |
final class MyMultiListener | |
{ | |
#[AsEventListener] | |
public function onCustomEvent(CustomEvent $event): void |
There seems to be an implicit assumption here that classCustomEvent
has been defined and exists in the same namespace.
IfCustomEvent
is defined in theApp\Event
namespace used by other examples in this file then theAsEventListener
attribute fails silently and the listener method will never do anything.
Specifically, there is a missinguse
statement here and it's not easy to debug.
Metadata
Metadata
Assignees
Labels
No labels