You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ CHANGELOG
5
5
-----
6
6
7
7
* The signature of the `EventDispatcherInterface::dispatch()` method should be updated to `dispatch($event, string $eventName = null)`, not doing so is deprecated
8
+
* added the `EventListenerInterface` interface and guessed event name from the `__invoke` method signature.
if (!$reflection = $container->getReflectionClass($class)) {
76
+
thrownewInvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
77
+
}
78
+
}
79
+
if (!$reflection->implementsInterface(EventListenerInterface::class)) {
80
+
thrownewInvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags or implements the EventListenerInterface interface .', $id, $this->listenerTag));
thrownew \InvalidArgumentException(sprintf('Invalid EventListener "%s": class "%s" must have an "__invoke()" method.', $serviceId, $handlerClass->getName()));
154
+
}
155
+
156
+
$parameters = $method->getParameters();
157
+
if (1 > \count($parameters)) {
158
+
thrownew \InvalidArgumentException(sprintf('Invalid EventListener "%s": method "%s::__invoke()" must have, at least, one argument corresponding to the event it handles.', $serviceId, $handlerClass->getName()));
159
+
}
160
+
161
+
if (!$type = $parameters[0]->getType()) {
162
+
thrownew \InvalidArgumentException(sprintf('Invalid EventListener "%s": argument "$%s" of method "%s::__invoke()" must have a type-hint corresponding to the event class it handles.', $serviceId, $parameters[0]->getName(), $handlerClass->getName()));
163
+
}
164
+
165
+
if ($type->isBuiltin()) {
166
+
thrownew \InvalidArgumentException(sprintf('Invalid EventListener "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class, "%s" given.', $serviceId, $parameters[0]->getName(), $handlerClass->getName(), $type));
0 commit comments