mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Utils: fixed testValidInstance() not accepting the same valid class for both className and baseName
this caused problems in PlayerCreationEvent because plugins set the base class and then set the player class to the same thing.
This commit is contained in:
parent
94f4ef5862
commit
4178c81209
@ -519,12 +519,10 @@ final class Utils{
|
||||
if(!class_exists($className)){
|
||||
throw new \InvalidArgumentException("Class $className does not exist");
|
||||
}
|
||||
$base = new \ReflectionClass($baseName);
|
||||
$class = new \ReflectionClass($className);
|
||||
|
||||
if(!$class->isSubclassOf($baseName)){
|
||||
throw new \InvalidArgumentException("Class $className does not " . ($base->isInterface() ? "implement" : "extend") . " " . $baseName);
|
||||
if(!is_a($className, $baseName, true)){
|
||||
throw new \InvalidArgumentException("Class $className does not extend or implement $baseName");
|
||||
}
|
||||
$class = new \ReflectionClass($className);
|
||||
if(!$class->isInstantiable()){
|
||||
throw new \InvalidArgumentException("Class $className cannot be constructed");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user