if ($handlerClass->
implementsInterface(MessageHandlerInterface::
class)) { trigger_deprecation('symfony/messenger', '6.2', 'Implementing "%s" is deprecated, use the "%s" attribute instead.', MessageHandlerInterface::
class, AsMessageHandler::
class);
} try { $method =
$handlerClass->
getMethod($methodName);
} catch (\ReflectionException
) { throw new RuntimeException(sprintf('Invalid handler service "%s": class "%s" must have an "%s()" method.',
$serviceId,
$handlerClass->
getName(),
$methodName));
} if (0 ===
$method->
getNumberOfRequiredParameters()) { throw new RuntimeException(sprintf('Invalid handler service "%s": method "%s::%s()" requires at least one argument, first one being the message it handles.',
$serviceId,
$handlerClass->
getName(),
$methodName));
} $parameters =
$method->
getParameters();
/** @var \ReflectionNamedType|\ReflectionUnionType|null */
$type =
$parameters[0
]->
getType();
if (!
$type) { throw new RuntimeException(sprintf('Invalid handler service "%s": argument "$%s" of method "%s::%s()" must have a type-hint corresponding to the message class it handles.',
$serviceId,
$parameters[0
]->
getName(),
$handlerClass->
getName(),
$methodName));
}