NarrowEventDispatcherAutowiringTypeRector

Change deprecated autowired EventDispatcherInterface from the component to the contracts one, if only dispatch() is called on it

-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

 final class SomeService
 {
     public function __construct(
         private EventDispatcherInterface $eventDispatcher
     ) {
     }

     public function run(object $event): void
     {
         $this->eventDispatcher->dispatch($event);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony82\Rector\Class_\NarrowEventDispatcherAutowiringTypeRector;

return RectorConfig::configure()
    ->withRules([
        NarrowEventDispatcherAutowiringTypeRector::class,
    ]);
PACKAGE:  symfony/dependency-injection >=8.2

Other rules in the symfony/dependency-injection set