diff --git a/src/Argument/ArgumentResolverTrait.php b/src/Argument/ArgumentResolverTrait.php index a371f82..5ff90e8 100644 --- a/src/Argument/ArgumentResolverTrait.php +++ b/src/Argument/ArgumentResolverTrait.php @@ -51,14 +51,23 @@ public function reflectArguments(ReflectionFunctionAbstract $method, array $args { $arguments = array_map(function (ReflectionParameter $param) use ($method, $args) { $name = $param->getName(); - $class = $param->getClass(); + $type = $param->getType(); if (array_key_exists($name, $args)) { return $args[$name]; } - if (! is_null($class)) { - return $class->getName(); + if ($type) { + if (PHP_VERSION_ID >= 70100) { + $typeName = $type->getName(); + } else { + $typeName = (string) $type; + } + + // in PHP 8, nullable arguments have "?" prefix + $typeHint = ltrim($typeName, '?'); + + return $typeHint; } if ($param->isDefaultValueAvailable()) {