Skip to content

Commit

Permalink
Fix PHP 8 deprecation (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsythe-godaddy authored Dec 21, 2020
1 parent f48890b commit 520bb1d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/StandardReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ public function getCtorParams($class)

public function getParamTypeHint(\ReflectionFunctionAbstract $function, \ReflectionParameter $param)
{
return ($reflectionClass = $param->getClass())
? $reflectionClass->getName()
: null;
// php 8 deprecates getClass method
if (PHP_VERSION_ID >= 80000) {
$reflectionClass = $param->getType() ? (string) $param->getType() : null;
} else {
/** @var ?\ReflectionClass $reflectionClass */
$reflectionClass = $param->getClass();
if ($reflectionClass) {
$reflectionClass = $reflectionClass->getName();
}
}
return $reflectionClass ?? null;
}

public function getFunction($functionName)
Expand Down

0 comments on commit 520bb1d

Please sign in to comment.