Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 303051a

Browse files
committed
Make sure first argument is required
1 parent 58ef481 commit 303051a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ private function guessHandledClasses(\ReflectionClass $handlerClass, string $ser
206206
throw new RuntimeException(sprintf('Invalid handler service "%s": class "%s" must have an "__invoke()" method.', $serviceId, $handlerClass->getName()));
207207
}
208208

209-
$parameters = $method->getParameters();
210-
if (0 === \count($parameters)) {
209+
if (0 === $method->getNumberOfRequiredParameters()) {
211210
throw new RuntimeException(sprintf('Invalid handler service "%s": method "%s::__invoke()" first argument must correspond to the message it handles.', $serviceId, $handlerClass->getName()));
212211
}
213212

213+
$parameters = $method->getParameters();
214214
if (!$type = $parameters[0]->getType()) {
215215
throw new RuntimeException(sprintf('Invalid handler service "%s": argument "$%s" of method "%s::__invoke()" must have a type-hint corresponding to the message class it handles.', $serviceId, $parameters[0]->getName(), $handlerClass->getName()));
216216
}

0 commit comments

Comments
 (0)