[EventDispatcher] Better error reporting when arguments to dispatch() are swapped
This commit is contained in:
parent
da459d731f
commit
54aac56ab8
@ -54,7 +54,7 @@ class EventDispatcher implements EventDispatcherInterface
|
|||||||
|
|
||||||
if (\is_object($event)) {
|
if (\is_object($event)) {
|
||||||
$eventName = $eventName ?? \get_class($event);
|
$eventName = $eventName ?? \get_class($event);
|
||||||
} elseif (\is_string($event) && (null === $eventName || $eventName instanceof Event)) {
|
} elseif (\is_string($event) && (null === $eventName || $eventName instanceof ContractsEvent || $eventName instanceof Event)) {
|
||||||
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
|
||||||
$swap = $event;
|
$swap = $event;
|
||||||
$event = $eventName ?? new Event();
|
$event = $eventName ?? new Event();
|
||||||
|
@ -59,7 +59,7 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface
|
|||||||
|
|
||||||
if (\is_object($event)) {
|
if (\is_object($event)) {
|
||||||
$eventName = $eventName ?? \get_class($event);
|
$eventName = $eventName ?? \get_class($event);
|
||||||
} elseif (\is_string($event) && (null === $eventName || $eventName instanceof Event)) {
|
} elseif (\is_string($event) && (null === $eventName || $eventName instanceof ContractsEvent || $eventName instanceof Event)) {
|
||||||
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', ContractsEventDispatcherInterface::class), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as the first argument is deprecated since Symfony 4.3, pass it as the second argument and provide the event object as the first argument instead.', ContractsEventDispatcherInterface::class), E_USER_DEPRECATED);
|
||||||
$swap = $event;
|
$swap = $event;
|
||||||
$event = $eventName ?? new Event();
|
$event = $eventName ?? new Event();
|
||||||
|
Reference in New Issue
Block a user