From 54df46c4e7501a87c98ddfb37f0b86658ee50b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 17 Jul 2019 23:48:41 +0200 Subject: [PATCH] Use getName() if available ReflectionType::__toString() has been deprecated in favor of ReflectionNamedType::getName(). The documentation states that this: > As of PHP 7.1.0, ReflectionType::__toString() is deprecated, and > ReflectionParamater::getType() *may* return an instance of > ReflectionNamedType. To get the name of the parameter type, > ReflectionNamedType() is available in this case. Since this implies there is no guarantee to have a ReflectionNamedType, I added a type check, falling back to the use of the deprecated API. --- .../Component/Messenger/DependencyInjection/MessengerPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index 6443d65dabe67..b83272792f4d0 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -218,7 +218,7 @@ private function guessHandledClasses(\ReflectionClass $handlerClass, string $ser } if ($type->isBuiltin()) { - throw new RuntimeException(sprintf('Invalid handler service "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class , "%s" given.', $serviceId, $parameters[0]->getName(), $handlerClass->getName(), $type)); + throw new RuntimeException(sprintf('Invalid handler service "%s": type-hint of argument "$%s" in method "%s::__invoke()" must be a class , "%s" given.', $serviceId, $parameters[0]->getName(), $handlerClass->getName(), $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type)); } return [$parameters[0]->getType()->getName()];