From ace74ef866453d2ae87e3d15be181dc00343dbbf Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sat, 12 Oct 2019 22:40:03 +0200 Subject: [PATCH 1/2] Fix ReflectionType::__toString() is deprecated As of PHP 7.1.0, ReflectionType::__toString() is deprecated, and ReflectionParameter::getType() may return an instance of ReflectionNamedType. To get the name of the parameter type, ReflectionNamedType() is available in this case. https://www.php.net/manual/en/reflectionparameter.gettype.php Signed-off-by: Daniel Kesselberg --- .../AppFramework/Utility/ControllerMethodReflector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index ef4a1959d6..7eee2ac8e5 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -76,8 +76,8 @@ class ControllerMethodReflector implements IControllerMethodReflector { // over phpdoc annotations if (method_exists($param, 'getType')) { $type = $param->getType(); - if ($type !== null) { - $this->types[$param->getName()] = (string) $type; + if ($type instanceof \ReflectionNamedType) { + $this->types[$param->getName()] = $type->getName(); } } From 0ecc70c4970dfe6ef1d164c427379738680a5f29 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Sat, 12 Oct 2019 22:55:07 +0200 Subject: [PATCH 2/2] Assume that getType is available From PHP7 getType is always available. No need to check it nowdays. Signed-off-by: Daniel Kesselberg --- .../Utility/ControllerMethodReflector.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index 7eee2ac8e5..fd42606cf5 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -72,13 +72,10 @@ class ControllerMethodReflector implements IControllerMethodReflector { } foreach ($reflection->getParameters() as $param) { - // extract type information from PHP 7 scalar types and prefer them - // over phpdoc annotations - if (method_exists($param, 'getType')) { - $type = $param->getType(); - if ($type instanceof \ReflectionNamedType) { - $this->types[$param->getName()] = $type->getName(); - } + // extract type information from PHP 7 scalar types and prefer them over phpdoc annotations + $type = $param->getType(); + if ($type instanceof \ReflectionNamedType) { + $this->types[$param->getName()] = $type->getName(); } $default = null;