Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AsEventListener Example Might Never Work #21002

Open
@miqrogroove

Description

@miqrogroove

I found a severe pitfall in this example code:

: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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp