mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 04:15:04 +00:00
EnumTrait: use a better method to initialize enums
this method is simpler, and is also safe at the native type level. Coincidentally, it also eliminates 30 PHPStan false-positives.
This commit is contained in:
@@ -57,8 +57,8 @@ final class DyeColor{
|
||||
/** @var DyeColor[] */
|
||||
private static $numericIdMap = [];
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new DyeColor("white", "White", 0, new Color(0xf0, 0xf0, 0xf0)),
|
||||
new DyeColor("orange", "Orange", 1, new Color(0xf9, 0x80, 0x1d)),
|
||||
new DyeColor("magenta", "Magenta", 2, new Color(0xc7, 0x4e, 0xbd)),
|
||||
@@ -75,7 +75,7 @@ final class DyeColor{
|
||||
new DyeColor("green", "Green", 13, new Color(0x5e, 0x7c, 0x16)),
|
||||
new DyeColor("red", "Red", 14, new Color(0xb0, 0x2e, 0x26)),
|
||||
new DyeColor("black", "Black", 15, new Color(0x1d, 0x1d, 0x21)),
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
protected static function register(DyeColor $color) : void{
|
||||
|
@@ -46,15 +46,15 @@ final class SkullType{
|
||||
/** @var SkullType[] */
|
||||
private static $numericIdMap = [];
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new SkullType("skeleton", "Skeleton Skull", 0),
|
||||
new SkullType("wither_skeleton", "Wither Skeleton Skull", 1),
|
||||
new SkullType("zombie", "Zombie Head", 2),
|
||||
new SkullType("player", "Player Head", 3),
|
||||
new SkullType("creeper", "Creeper Head", 4),
|
||||
new SkullType("dragon", "Dragon Head", 5)
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
protected static function register(SkullType $type) : void{
|
||||
|
@@ -37,11 +37,11 @@ use pocketmine\utils\EnumTrait;
|
||||
final class SlabType{
|
||||
use EnumTrait;
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("bottom"),
|
||||
new self("top"),
|
||||
new self("double")
|
||||
];
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -39,13 +39,13 @@ use pocketmine\utils\EnumTrait;
|
||||
final class StairShape{
|
||||
use EnumTrait;
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new self("straight"),
|
||||
new self("inner_left"),
|
||||
new self("inner_right"),
|
||||
new self("outer_left"),
|
||||
new self("outer_right")
|
||||
];
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -46,15 +46,15 @@ final class TreeType{
|
||||
/** @var TreeType[] */
|
||||
private static $numericIdMap = [];
|
||||
|
||||
protected static function setup() : iterable{
|
||||
return [
|
||||
protected static function setup() : void{
|
||||
self::registerAll(
|
||||
new TreeType("oak", "Oak", 0),
|
||||
new TreeType("spruce", "Spruce", 1),
|
||||
new TreeType("birch", "Birch", 2),
|
||||
new TreeType("jungle", "Jungle", 3),
|
||||
new TreeType("acacia", "Acacia", 4),
|
||||
new TreeType("dark_oak", "Dark Oak", 5)
|
||||
];
|
||||
);
|
||||
}
|
||||
|
||||
protected static function register(TreeType $type) : void{
|
||||
|
Reference in New Issue
Block a user