Skip to content

Commit 7c87da1

Browse files
authored
Merge pull request #240 from DerManoMann/reflectionparameter-getclass-deprecated-php8
Use ReflectionParameter::getType() instead of getClass()
2 parents 41f77e8 + 321abc5 commit 7c87da1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/DocBlock/StandardTagFactory.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use phpDocumentor\Reflection\FqsenResolver;
3737
use phpDocumentor\Reflection\Types\Context as TypeContext;
3838
use ReflectionMethod;
39+
use ReflectionNamedType;
3940
use ReflectionParameter;
4041
use Webmozart\Assert\Assert;
4142
use function array_merge;
@@ -254,10 +255,16 @@ private function getArgumentsForParametersFromWiring(array $parameters, array $l
254255
{
255256
$arguments = [];
256257
foreach ($parameters as $parameter) {
257-
$class = $parameter->getClass();
258+
$type = $parameter->getType();
258259
$typeHint = null;
259-
if ($class !== null) {
260-
$typeHint = $class->getName();
260+
if ($type instanceof ReflectionNamedType) {
261+
$typeHint = $type->getName();
262+
if ($typeHint === 'self') {
263+
$declaringClass = $parameter->getDeclaringClass();
264+
if ($declaringClass !== null) {
265+
$typeHint = $declaringClass->getName();
266+
}
267+
}
261268
}
262269

263270
if (isset($locator[$typeHint])) {

0 commit comments

Comments
 (0)