EntityFactory: remove requirement for $className as return type on creation funcs

since the removal of EntityFactory::create() this isn't needed anymore, since these creation functions are only used for creating entities loaded from disk.
This commit is contained in:
Dylan K. Taylor 2020-08-17 13:20:34 +01:00
parent bf401421fa
commit 40d49b88dd

View File

@ -161,12 +161,11 @@ final class EntityFactory{
}
/**
* @phpstan-param class-string<Entity> $baseClass
* @phpstan-param \Closure(World, CompoundTag) : Entity $creationFunc
*/
private static function validateCreationFunc(string $baseClass, \Closure $creationFunc) : void{
private static function validateCreationFunc(\Closure $creationFunc) : void{
$sig = new CallbackType(
new ReturnType($baseClass),
new ReturnType(Entity::class),
new ParameterType("world", World::class),
new ParameterType("nbt", CompoundTag::class)
);
@ -193,7 +192,7 @@ final class EntityFactory{
throw new \InvalidArgumentException("At least one save name must be provided");
}
Utils::testValidInstance($className, Entity::class);
self::validateCreationFunc($className, $creationFunc);
self::validateCreationFunc($creationFunc);
foreach($saveNames as $name){
$this->creationFuncs[$name] = $creationFunc;