Merge pull request #240 from DerManoMann/reflectionparameter-getclass-deprecated-php8

Use ReflectionParameter::getType() instead of getClass()
This commit is contained in:
Jaap van Otterdijk
2020-07-07 16:44:20 +02:00
committed by GitHub
+10 -3
View File
@@ -36,6 +36,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Version;
use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext; use phpDocumentor\Reflection\Types\Context as TypeContext;
use ReflectionMethod; use ReflectionMethod;
use ReflectionNamedType;
use ReflectionParameter; use ReflectionParameter;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
use function array_merge; use function array_merge;
@@ -254,10 +255,16 @@ final class StandardTagFactory implements TagFactory
{ {
$arguments = []; $arguments = [];
foreach ($parameters as $parameter) { foreach ($parameters as $parameter) {
$class = $parameter->getClass(); $type = $parameter->getType();
$typeHint = null; $typeHint = null;
if ($class !== null) { if ($type instanceof ReflectionNamedType) {
$typeHint = $class->getName(); $typeHint = $type->getName();
if ($typeHint === 'self') {
$declaringClass = $parameter->getDeclaringClass();
if ($declaringClass !== null) {
$typeHint = $declaringClass->getName();
}
}
} }
if (isset($locator[$typeHint])) { if (isset($locator[$typeHint])) {