mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
make use of phpstan class-string in some areas
This commit is contained in:
@ -45,6 +45,8 @@ abstract class LevelProviderManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<LevelProvider> $class
|
||||
*
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@ -69,10 +71,11 @@ abstract class LevelProviderManager{
|
||||
* Returns a LevelProvider class for this path, or null
|
||||
*
|
||||
* @return string|null
|
||||
* @phpstan-return class-string<LevelProvider>|null
|
||||
*/
|
||||
public static function getProvider(string $path){
|
||||
foreach(self::$providers as $provider){
|
||||
/** @var $provider LevelProvider */
|
||||
/** @phpstan-var class-string<LevelProvider> $provider */
|
||||
if($provider::isValid($path)){
|
||||
return $provider;
|
||||
}
|
||||
@ -85,6 +88,7 @@ abstract class LevelProviderManager{
|
||||
* Returns a LevelProvider by name, or null if not found
|
||||
*
|
||||
* @return string|null
|
||||
* @phpstan-return class-string<LevelProvider>|null
|
||||
*/
|
||||
public static function getProviderByName(string $name){
|
||||
return self::$providers[trim(strtolower($name))] ?? null;
|
||||
|
@ -51,6 +51,7 @@ final class GeneratorManager{
|
||||
* @param string $class Fully qualified name of class that extends \pocketmine\level\generator\Generator
|
||||
* @param string $name Alias for this generator type that can be written in configs
|
||||
* @param bool $overwrite Whether to force overwriting any existing registered generator with the same name
|
||||
* @phpstan-param class-string<Generator> $class
|
||||
*/
|
||||
public static function addGenerator(string $class, string $name, bool $overwrite = false) : void{
|
||||
if(!is_subclass_of($class, Generator::class)){
|
||||
@ -78,7 +79,9 @@ final class GeneratorManager{
|
||||
*
|
||||
* @param bool $throwOnMissing @deprecated this is for backwards compatibility only
|
||||
*
|
||||
* @return string|Generator Name of class that extends Generator (not an actual Generator object)
|
||||
* @return string Name of class that extends Generator
|
||||
* @phpstan-return class-string<Generator>
|
||||
*
|
||||
* @throws \InvalidArgumentException if the generator type isn't registered
|
||||
*/
|
||||
public static function getGenerator(string $name, bool $throwOnMissing = false){
|
||||
@ -96,6 +99,7 @@ final class GeneratorManager{
|
||||
* Returns the registered name of the given Generator class.
|
||||
*
|
||||
* @param string $class Fully qualified name of class that extends \pocketmine\level\generator\Generator
|
||||
* @phpstan-param class-string<Generator> $class
|
||||
*/
|
||||
public static function getGeneratorName(string $class) : string{
|
||||
foreach(self::$list as $name => $c){
|
||||
|
Reference in New Issue
Block a user