Fixed PHP 8.0 deprecation error

This commit is contained in:
Dylan K. Taylor 2021-01-15 18:10:09 +00:00
parent e156fb47e8
commit 988cf7f535
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -703,7 +703,15 @@ class PluginManager{
$handlerClosure = $method->getClosure($listener);
try{
$eventClass = $parameters[0]->getClass();
$paramType = $parameters[0]->getType();
//isBuiltin() returns false for builtin classes ..................
if($paramType instanceof \ReflectionNamedType && !$paramType->isBuiltin()){
/** @phpstan-var class-string $paramClass */
$paramClass = $paramType->getName();
$eventClass = new \ReflectionClass($paramClass);
}else{
$eventClass = null;
}
}catch(\ReflectionException $e){ //class doesn't exist
if(isset($tags["softDepend"]) && !isset($this->plugins[$tags["softDepend"]])){
$this->server->getLogger()->debug("Not registering @softDepend listener " . Utils::getNiceClosureName($handlerClosure) . "() because plugin \"" . $tags["softDepend"] . "\" not found");