Skip to content

Commit

Permalink
php8: address ReflectionParameter::getClass deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdosoftei committed Aug 11, 2020
1 parent d3d4ec3 commit 2ed085d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/functions.php
Expand Up @@ -342,7 +342,17 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
return true;
}

$expectedClass = $parameters[0]->getClass();
$expectedClass = null;
if (method_exists($parameters[0], 'getType')) {
$type = $parameters[0]->getType();
if (!$type || $type->isBuiltin()) {
return true;
}

$expectedClass = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type);
} else {
$expectedClass = $parameters[0]->getClass();
}

if (!$expectedClass) {
return true;
Expand Down

0 comments on commit 2ed085d

Please sign in to comment.