psalm / psalm-plugin-symfony

Psalm Plugin for Symfony
MIT License
228 stars 53 forks source link

Add issue for event listener pointing to wrong method name #318

Open ostrolucky opened 1 year ago

ostrolucky commented 1 year ago
#[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