Find a Rector rule
Find the best Rector rule to solve your problem. Searching through 1074 rules.
Found 3 rules, grouped by set: Clear
symfony/event-dispatcher
3 matches
EventSubscriberToAttributeRector
symfony/event-dispatcher >=5.4
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()
{
}
}
EventDispatcherParentConstructRector
symfony/event-dispatcher >=4.3
Removes parent construct method call in EventDispatcher class
use Symfony\Component\EventDispatcher\EventDispatcher;
final class SomeEventDispatcher extends EventDispatcher
{
public function __construct()
{
$value = 1000;
+ parent::__construct();
}
}
MakeDispatchFirstArgumentEventRector
symfony/event-dispatcher >=4.3 <7.0
Make event object a first argument of dispatch() method, event name as second
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class SomeClass
{
public function run(EventDispatcherInterface $eventDispatcher)
{
- $eventDispatcher->dispatch('event_name', new Event());
+ $eventDispatcher->dispatch(new Event(), 'event_name');
}
}