psalm-plugin-symfony icon indicating copy to clipboard operation
psalm-plugin-symfony copied to clipboard

Add issue for event listener pointing to wrong method name

Open ostrolucky opened this issue 1 year ago • 0 comments

#[AsEventListener(ImportProcessEvent::USER_IMPORT_CONFIRMED, priority: 100)]
final class UserImportListener
{
    public function dispatchAccess(ImportProcessEvent $event): void
    {
    }
}

This should be reported as an issue, because in runtime it produces

Uncaught PHP Exception TypeError: "Failed to create closure from callable: class UserImportListener does not have a method "onImportConfirmed" at /srv/api/vendor/symfony/event-dispatcher/EventDispatcher.php line 270

Method should be renamed to __invoke or onImportConfirmed

ostrolucky avatar Jul 06 '23 08:07 ostrolucky