EventSubscriberToAttributeRector

Change Symfony EventSubscriberInterface implementation to #[AsEventListener] attributes

-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

-class SomeEventSubscriber implements EventSubscriberInterface
+class SomeEventSubscriber
 {
-    public static function getSubscribedEvents(): array
-    {
-        return ['some_event' => ['methodToBeCalled', 10]];
-    }
-
+    #[AsEventListener(event: 'some_event', priority: 10)]
     public function methodToBeCalled()
     {
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\CodeQuality\Rector\Class_\EventSubscriberToAttributeRector;

return RectorConfig::configure()
    ->withRules([
        EventSubscriberToAttributeRector::class,
    ]);
PACKAGE:  symfony/event-dispatcher >=5.4

Other rules in the symfony/event-dispatcher set