Skip to content

Commit 520bb1d

Browse files
Fix PHP 8 deprecation (#189)
1 parent f48890b commit 520bb1d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/StandardReflector.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ public function getCtorParams($class)
2525

2626
public function getParamTypeHint(\ReflectionFunctionAbstract $function, \ReflectionParameter $param)
2727
{
28-
return ($reflectionClass = $param->getClass())
29-
? $reflectionClass->getName()
30-
: null;
28+
// php 8 deprecates getClass method
29+
if (PHP_VERSION_ID >= 80000) {
30+
$reflectionClass = $param->getType() ? (string) $param->getType() : null;
31+
} else {
32+
/** @var ?\ReflectionClass $reflectionClass */
33+
$reflectionClass = $param->getClass();
34+
if ($reflectionClass) {
35+
$reflectionClass = $reflectionClass->getName();
36+
}
37+
}
38+
return $reflectionClass ?? null;
3139
}
3240

3341
public function getFunction($functionName)

0 commit comments

Comments
 (0)