From 321abc52ae1617bd6f73b22c35fbdf199dc226ab Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Fri, 3 Jul 2020 14:42:39 +1200 Subject: [PATCH] Handle typehint value 'self' --- src/DocBlock/StandardTagFactory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DocBlock/StandardTagFactory.php b/src/DocBlock/StandardTagFactory.php index 8e412fe..e64b587 100644 --- a/src/DocBlock/StandardTagFactory.php +++ b/src/DocBlock/StandardTagFactory.php @@ -36,6 +36,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Version; use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\Types\Context as TypeContext; use ReflectionMethod; +use ReflectionNamedType; use ReflectionParameter; use Webmozart\Assert\Assert; use function array_merge; @@ -256,8 +257,14 @@ final class StandardTagFactory implements TagFactory foreach ($parameters as $parameter) { $type = $parameter->getType(); $typeHint = null; - if ($type instanceof \ReflectionNamedType) { + if ($type instanceof ReflectionNamedType) { $typeHint = $type->getName(); + if ($typeHint === 'self') { + $declaringClass = $parameter->getDeclaringClass(); + if ($declaringClass !== null) { + $typeHint = $declaringClass->getName(); + } + } } if (isset($locator[$typeHint])) {