Upgrading symfony/event-dispatcher 3 to 4
Breakingv3.4.47 → v4.4.44Breaking1Deprecated3New4Changed2Fixed5
BreakingUpgrade verdict
1 breaking change.
In plain terms
- The ContainerAwareEventDispatcher helper class is gone, so code that used it must switch to another dispatcher.
- Code that calls the event dispatcher with the old argument order should be updated to the new signature.
- The built-in Event class is being retired; use the contracts package version instead.
- The interface used to trace event dispatching is deprecated and will be removed in a future version.
Must act 4 items need code or config changes
PHP requirement changed in v4.4.9: ^5.5.9|>=7.0.8 → >=7.1.3.
Adds symfony/event-dispatcher-contracts ^1.1, symfony/polyfill-php80 ^1.16.
What you must change
Breaking1
Removes the ContainerAwareEventDispatcher class.
ContainerAwareEventDispatcherDeprecations to plan for
Deprecated3
Deprecates the old EventDispatcherInterface::dispatch() signature; update it to dispatch($event, string $eventName = null).
EventDispatcherInterface::dispatch()Deprecates the Event class in favor of Symfony\Contracts\EventDispatcher\Event.
EventSymfony\Contracts\EventDispatcher\EventDeprecates the
TraceableEventDispatcherInterface.TraceableEventDispatcherInterfaceAPI changes
Generated by DepDelta from published PHP source. Not mixed with prose notes.
- removed:
class ContainerAwareEventDispatcher extends EventDispatcher - removed:
constructor ContainerAwareEventDispatcher(ContainerInterface $container) - removed:
method ContainerAwareEventDispatcher.addListenerService($eventName, $callback, $priority = …) - removed:
method ContainerAwareEventDispatcher.addSubscriberService($serviceId, $class) - removed:
method ContainerAwareEventDispatcher.getContainer() - removed:
method ContainerAwareEventDispatcher.getListenerPriority($eventName, $listener) - removed:
method ContainerAwareEventDispatcher.getListeners($eventName = …) - removed:
method ContainerAwareEventDispatcher.hasListeners($eventName = …) - removed:
method ContainerAwareEventDispatcher.removeListener($eventName, $listener) - removed:
method EventDispatcherInterface.dispatch($eventName, Event $event = …) - removed:
protected method ContainerAwareEventDispatcher.lazyLoad($eventName) - changed:
interface EventDispatcherInterface → interface EventDispatcherInterface extends ContractsEventDispatcherInterface - changed:
method EventDispatcher.dispatch($eventName, Event $event = …) → method EventDispatcher.dispatch($event) - changed:
method ImmutableEventDispatcher.dispatch($eventName, Event $event = …) → method ImmutableEventDispatcher.dispatch($event) - added:
constructor EventDispatcher() - added:
constructor LegacyEventProxy($event) - added:
final class LegacyEventDispatcherProxy implements EventDispatcherInterface - added:
final class LegacyEventProxy extends Event - added:
method LegacyEventDispatcherProxy.__call($method, $arguments) - added:
method LegacyEventDispatcherProxy.addListener($eventName, $listener, $priority = …) - added:
method LegacyEventDispatcherProxy.addSubscriber(EventSubscriberInterface $subscriber) - added:
method LegacyEventDispatcherProxy.dispatch($event) - added:
method LegacyEventDispatcherProxy.getListenerPriority($eventName, $listener): ?int - added:
method LegacyEventDispatcherProxy.getListeners($eventName = …): array - added:
method LegacyEventDispatcherProxy.hasListeners($eventName = …): bool - added:
method LegacyEventDispatcherProxy.removeListener($eventName, $listener) - added:
method LegacyEventDispatcherProxy.removeSubscriber(EventSubscriberInterface $subscriber) - added:
method LegacyEventProxy.__call($name, $args) - added:
method LegacyEventProxy.getEvent() - added:
method LegacyEventProxy.isPropagationStopped(): bool - added:
method LegacyEventProxy.stopPropagation() - added:
protected method EventDispatcher.callListeners(iterable $listeners, string $eventName, $event) - added:
static method LegacyEventDispatcherProxy.decorate(?ContractsEventDispatcherInterface $dispatcher): ?ContractsEventDispatcherInterface
- changed:
constructor TraceableEventDispatcher(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = …) → constructor TraceableEventDispatcher(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = …, RequestStack $requestStack = …) - changed:
constructor WrappedListener($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = …) → constructor WrappedListener($listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = …) - changed:
interface TraceableEventDispatcherInterface extends EventDispatcherInterface → interface TraceableEventDispatcherInterface extends EventDispatcherInterface, ResetInterface - changed:
method TraceableEventDispatcher.dispatch($eventName, Event $event = …) → method TraceableEventDispatcher.dispatch($event) - added:
method TraceableEventDispatcher.getOrphanedEvents(): array - added:
protected method TraceableEventDispatcher.afterDispatch(string $eventName, $event) - added:
protected method TraceableEventDispatcher.beforeDispatch(string $eventName, $event)
- changed:
constructor RegisterListenersPass($dispatcherService = …, $listenerTag = …, $subscriberTag = …) → constructor RegisterListenersPass(string $dispatcherService = …, string $listenerTag = …, string $subscriberTag = …, string $eventAliasesParameter = …) - changed:
static method ExtractingEventDispatcher.getSubscribedEvents() → static method ExtractingEventDispatcher.getSubscribedEvents(): array - added:
class AddEventAliasesPass implements CompilerPassInterface - added:
constructor AddEventAliasesPass(array $eventAliases, string $eventAliasesParameter = …) - added:
method AddEventAliasesPass.process(ContainerBuilder $container): void - added:
protected property RegisterListenersPass.eventAliasesParameter - added:
static property ExtractingEventDispatcher.aliases