diff --git a/src/DI/PhpReflection.php b/src/DI/PhpReflection.php index a8e1cad58..07860fd58 100644 --- a/src/DI/PhpReflection.php +++ b/src/DI/PhpReflection.php @@ -83,7 +83,7 @@ public static function getParameterType(\ReflectionParameter $param) public static function getReturnType(\ReflectionFunctionAbstract $func) { if (PHP_VERSION_ID >= 70000 && $func->hasReturnType()) { - $type = (string) $func->getReturnType(); + $type = PHP_VERSION_ID >= 70100 ? $func->getReturnType()->getName() : (string) $func->getReturnType(); return strtolower($type) === 'self' ? $func->getDeclaringClass()->getName() : $type; } $type = preg_replace('#[|\s].*#', '', (string) self::parseAnnotation($func, 'return')); diff --git a/tests/DI/PhpReflection.getReturnType.php71.phpt b/tests/DI/PhpReflection.getReturnType.php71.phpt new file mode 100644 index 000000000..d27ce1d51 --- /dev/null +++ b/tests/DI/PhpReflection.getReturnType.php71.phpt @@ -0,0 +1,90 @@ +