allow use of any iterable for enum initialization

this allows possible use of generators
This commit is contained in:
Dylan K. Taylor 2019-06-25 19:37:31 +01:00
parent 44b7239847
commit a6395c9ac7
9 changed files with 10 additions and 10 deletions

View File

@ -57,7 +57,7 @@ final class DyeColor{
/** @var DyeColor[] */
private static $numericIdMap = [];
protected static function setup() : array{
protected static function setup() : iterable{
return [
new DyeColor("white", "White", 0, new Color(0xf0, 0xf0, 0xf0)),
new DyeColor("orange", "Orange", 1, new Color(0xf9, 0x80, 0x1d)),

View File

@ -46,7 +46,7 @@ final class SkullType{
/** @var SkullType[] */
private static $numericIdMap = [];
protected static function setup() : array{
protected static function setup() : iterable{
return [
new SkullType("skeleton", "Skeleton Skull", 0),
new SkullType("wither_skeleton", "Wither Skeleton Skull", 1),

View File

@ -37,7 +37,7 @@ use pocketmine\utils\EnumTrait;
final class SlabType{
use EnumTrait;
protected static function setup() : array{
protected static function setup() : iterable{
return [
new self("bottom"),
new self("top"),

View File

@ -46,7 +46,7 @@ final class TreeType{
/** @var TreeType[] */
private static $numericIdMap = [];
protected static function setup() : array{
protected static function setup() : iterable{
return [
new TreeType("oak", "Oak", 0),
new TreeType("spruce", "Spruce", 1),

View File

@ -37,7 +37,7 @@ use pocketmine\utils\EnumTrait;
final class ItemUseResult{
use EnumTrait;
protected static function setup() : array{
protected static function setup() : iterable{
return [
new self("none"),
new self("fail"),

View File

@ -47,7 +47,7 @@ final class GameMode{
/** @var self[] */
protected static $magicNumberMap = [];
protected static function setup() : array{
protected static function setup() : iterable{
return [
new self("survival", 0, "Survival", "gameMode.survival", ["s", "0"]),
new self("creative", 1, "Creative", "gameMode.creative", ["c", "1"]),

View File

@ -36,7 +36,7 @@ use pocketmine\utils\EnumTrait;
final class PluginLoadOrder{
use EnumTrait;
protected static function setup() : array{
protected static function setup() : iterable{
return [
new self("startup"),
new self("postworld")

View File

@ -54,9 +54,9 @@ trait EnumTrait{
*
* (This ought to be private, but traits suck too much for that.)
*
* @return self[]
* @return self[]|iterable
*/
abstract protected static function setup() : array;
abstract protected static function setup() : iterable;
/**
* @internal Lazy-inits the enum if necessary.

View File

@ -41,7 +41,7 @@ class NoteInstrument{
__construct as Enum___construct;
}
protected static function setup() : array{
protected static function setup() : iterable{
return [
new self("piano", 0),
new self("bass_drum", 1),