Find the best Rector rule to solve your problem. Searching through 675 rules.

Found 2 rules:

MessageHandlerInterfaceToAttributeRector

Replaces MessageHandlerInterface with AsMessageHandler attribute

-use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
+use Symfony\Component\Messenger\Attribute\AsMessageHandler;

-class SmsNotificationHandler implements MessageHandlerInterface
+#[AsMessageHandler]
+class SmsNotificationHandler
 {
     public function __invoke(SmsNotification $message)
     {
         // ... do some work - like sending an SMS message!
     }
 }

MessageSubscriberInterfaceToAttributeRector

Replace MessageSubscriberInterface with AsMessageHandler attribute(s)

-use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
+use Symfony\Component\Messenger\Attribute\AsMessageHandler;

-class SmsNotificationHandler implements MessageSubscriberInterface
+class SmsNotificationHandler
 {
-    public function __invoke(SmsNotification $message)
+    #[AsMessageHandler]
+    public function handleSmsNotification(SmsNotification $message)
     {
         // ...
     }

+    #[AsMessageHandler(priority: 0, bus: 'messenger.bus.default']
     public function handleOtherSmsNotification(OtherSmsNotification $message)
     {
         // ...
-    }
-
-    public static function getHandledMessages(): iterable
-    {
-        // handle this message on __invoke
-        yield SmsNotification::class;
-
-        // also handle this message on handleOtherSmsNotification
-        yield OtherSmsNotification::class => [
-            'method' => 'handleOtherSmsNotification',
-            'priority' => 0,
-            'bus' => 'messenger.bus.default',
-        ];
     }
 }