diff --git a/build/generate-registry-annotations.php b/build/generate-registry-annotations.php new file mode 100644 index 000000000..71397590c --- /dev/null +++ b/build/generate-registry-annotations.php @@ -0,0 +1,76 @@ +getDocComment(); + if($docComment === false || (preg_match("/^\s*\*\s*\@see .+::_generateMethodAnnotations\(\)$/m", $docComment) !== 1 && preg_match("/^\s*\*\s*@generate-registry-docblock$/m", $docComment) !== 1)){ + continue; + } + echo "Found registry in $file\n"; + + $replacement = RegistryUtils::_generateMethodAnnotations($matches[1], $className::getAll()); + + $newContents = str_replace($docComment, $replacement, $contents); + if($newContents !== $contents){ + echo "Writing changed file $file\n"; + file_put_contents($file, $newContents); + }else{ + echo "No changes made to file $file\n"; + } +} + diff --git a/src/block/utils/DyeColor.php b/src/block/utils/DyeColor.php index 0c0761d61..d24775868 100644 --- a/src/block/utils/DyeColor.php +++ b/src/block/utils/DyeColor.php @@ -28,25 +28,25 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self WHITE() - * @method static self ORANGE() - * @method static self MAGENTA() - * @method static self LIGHT_BLUE() - * @method static self YELLOW() - * @method static self LIME() - * @method static self PINK() - * @method static self GRAY() - * @method static self LIGHT_GRAY() - * @method static self CYAN() - * @method static self PURPLE() - * @method static self BLUE() - * @method static self BROWN() - * @method static self GREEN() - * @method static self RED() - * @method static self BLACK() + * @method static DyeColor WHITE() + * @method static DyeColor ORANGE() + * @method static DyeColor MAGENTA() + * @method static DyeColor LIGHT_BLUE() + * @method static DyeColor YELLOW() + * @method static DyeColor LIME() + * @method static DyeColor PINK() + * @method static DyeColor GRAY() + * @method static DyeColor LIGHT_GRAY() + * @method static DyeColor CYAN() + * @method static DyeColor PURPLE() + * @method static DyeColor BLUE() + * @method static DyeColor BROWN() + * @method static DyeColor GREEN() + * @method static DyeColor RED() + * @method static DyeColor BLACK() */ final class DyeColor{ use EnumTrait { diff --git a/src/block/utils/RecordType.php b/src/block/utils/RecordType.php index 9846e3716..2ab3a27bd 100644 --- a/src/block/utils/RecordType.php +++ b/src/block/utils/RecordType.php @@ -29,20 +29,20 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. * This must be regenerated whenever registry members are added, removed or changed. - * @see RegistryTrait::_generateMethodAnnotations() + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self DISK_13() - * @method static self DISK_CAT() - * @method static self DISK_BLOCKS() - * @method static self DISK_CHIRP() - * @method static self DISK_FAR() - * @method static self DISK_MALL() - * @method static self DISK_MELLOHI() - * @method static self DISK_STAL() - * @method static self DISK_STRAD() - * @method static self DISK_WARD() - * @method static self DISK_11() - * @method static self DISK_WAIT() + * @method static RecordType DISK_13() + * @method static RecordType DISK_CAT() + * @method static RecordType DISK_BLOCKS() + * @method static RecordType DISK_CHIRP() + * @method static RecordType DISK_FAR() + * @method static RecordType DISK_MALL() + * @method static RecordType DISK_MELLOHI() + * @method static RecordType DISK_STAL() + * @method static RecordType DISK_STRAD() + * @method static RecordType DISK_WARD() + * @method static RecordType DISK_11() + * @method static RecordType DISK_WAIT() */ final class RecordType{ use EnumTrait { diff --git a/src/block/utils/SkullType.php b/src/block/utils/SkullType.php index 43934ff2d..70757b6fb 100644 --- a/src/block/utils/SkullType.php +++ b/src/block/utils/SkullType.php @@ -27,15 +27,15 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self SKELETON() - * @method static self WITHER_SKELETON() - * @method static self ZOMBIE() - * @method static self PLAYER() - * @method static self CREEPER() - * @method static self DRAGON() + * @method static SkullType SKELETON() + * @method static SkullType WITHER_SKELETON() + * @method static SkullType ZOMBIE() + * @method static SkullType PLAYER() + * @method static SkullType CREEPER() + * @method static SkullType DRAGON() */ final class SkullType{ use EnumTrait { diff --git a/src/block/utils/SlabType.php b/src/block/utils/SlabType.php index a56cf7ed4..287e7626f 100644 --- a/src/block/utils/SlabType.php +++ b/src/block/utils/SlabType.php @@ -27,12 +27,12 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self BOTTOM() - * @method static self TOP() - * @method static self DOUBLE() + * @method static SlabType BOTTOM() + * @method static SlabType TOP() + * @method static SlabType DOUBLE() */ final class SlabType{ use EnumTrait; diff --git a/src/block/utils/StairShape.php b/src/block/utils/StairShape.php index b46b19f11..32ed13413 100644 --- a/src/block/utils/StairShape.php +++ b/src/block/utils/StairShape.php @@ -27,14 +27,14 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self STRAIGHT() - * @method static self INNER_LEFT() - * @method static self INNER_RIGHT() - * @method static self OUTER_LEFT() - * @method static self OUTER_RIGHT() + * @method static StairShape STRAIGHT() + * @method static StairShape INNER_LEFT() + * @method static StairShape INNER_RIGHT() + * @method static StairShape OUTER_LEFT() + * @method static StairShape OUTER_RIGHT() */ final class StairShape{ use EnumTrait; diff --git a/src/block/utils/TreeType.php b/src/block/utils/TreeType.php index b3afdd95e..cd8443b22 100644 --- a/src/block/utils/TreeType.php +++ b/src/block/utils/TreeType.php @@ -27,15 +27,15 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self OAK() - * @method static self SPRUCE() - * @method static self BIRCH() - * @method static self JUNGLE() - * @method static self ACACIA() - * @method static self DARK_OAK() + * @method static TreeType OAK() + * @method static TreeType SPRUCE() + * @method static TreeType BIRCH() + * @method static TreeType JUNGLE() + * @method static TreeType ACACIA() + * @method static TreeType DARK_OAK() */ final class TreeType{ use EnumTrait { diff --git a/src/entity/effect/VanillaEffects.php b/src/entity/effect/VanillaEffects.php index 562682dad..bef5f7aa9 100644 --- a/src/entity/effect/VanillaEffects.php +++ b/src/entity/effect/VanillaEffects.php @@ -30,7 +30,7 @@ use function assert; /** * This doc-block is generated automatically, do not modify it manually. * This must be regenerated whenever registry members are added, removed or changed. - * @see RegistryTrait::_generateMethodAnnotations() + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * * @method static AbsorptionEffect ABSORPTION() * @method static Effect BLINDNESS() diff --git a/src/item/ItemUseResult.php b/src/item/ItemUseResult.php index 446945803..298381131 100644 --- a/src/item/ItemUseResult.php +++ b/src/item/ItemUseResult.php @@ -27,12 +27,12 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self NONE() - * @method static self FAIL() - * @method static self SUCCESS() + * @method static ItemUseResult NONE() + * @method static ItemUseResult FAIL() + * @method static ItemUseResult SUCCESS() */ final class ItemUseResult{ use EnumTrait; diff --git a/src/item/ToolTier.php b/src/item/ToolTier.php index 30e184e9f..08a1c0427 100644 --- a/src/item/ToolTier.php +++ b/src/item/ToolTier.php @@ -28,13 +28,13 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. * This must be regenerated whenever registry members are added, removed or changed. - * @see RegistryTrait::_generateMethodAnnotations() + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self WOOD() - * @method static self GOLD() - * @method static self STONE() - * @method static self IRON() - * @method static self DIAMOND() + * @method static ToolTier WOOD() + * @method static ToolTier GOLD() + * @method static ToolTier STONE() + * @method static ToolTier IRON() + * @method static ToolTier DIAMOND() */ final class ToolTier{ use EnumTrait { diff --git a/src/player/GameMode.php b/src/player/GameMode.php index 7d95513ba..e6f81e494 100644 --- a/src/player/GameMode.php +++ b/src/player/GameMode.php @@ -27,13 +27,13 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self SURVIVAL() - * @method static self CREATIVE() - * @method static self ADVENTURE() - * @method static self SPECTATOR() + * @method static GameMode SURVIVAL() + * @method static GameMode CREATIVE() + * @method static GameMode ADVENTURE() + * @method static GameMode SPECTATOR() */ final class GameMode{ use EnumTrait { diff --git a/src/player/UsedChunkStatus.php b/src/player/UsedChunkStatus.php index ce36ab86c..ff8c03089 100644 --- a/src/player/UsedChunkStatus.php +++ b/src/player/UsedChunkStatus.php @@ -28,11 +28,11 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. * This must be regenerated whenever registry members are added, removed or changed. - * @see RegistryTrait::_generateMethodAnnotations() + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self NEEDED() - * @method static self REQUESTED() - * @method static self SENT() + * @method static UsedChunkStatus NEEDED() + * @method static UsedChunkStatus REQUESTED() + * @method static UsedChunkStatus SENT() */ final class UsedChunkStatus{ use EnumTrait; diff --git a/src/plugin/PluginEnableOrder.php b/src/plugin/PluginEnableOrder.php index b79b19d90..e54427288 100644 --- a/src/plugin/PluginEnableOrder.php +++ b/src/plugin/PluginEnableOrder.php @@ -27,11 +27,11 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self STARTUP() - * @method static self POSTWORLD() + * @method static PluginEnableOrder STARTUP() + * @method static PluginEnableOrder POSTWORLD() */ final class PluginEnableOrder{ use EnumTrait; diff --git a/src/world/sound/NoteInstrument.php b/src/world/sound/NoteInstrument.php index cd37df98a..0ddc0eaef 100644 --- a/src/world/sound/NoteInstrument.php +++ b/src/world/sound/NoteInstrument.php @@ -27,14 +27,14 @@ use pocketmine\utils\EnumTrait; /** * This doc-block is generated automatically, do not modify it manually. - * This must be regenerated whenever enum members are added, removed or changed. - * @see EnumTrait::_generateMethodAnnotations() + * This must be regenerated whenever registry members are added, removed or changed. + * @see \pocketmine\utils\RegistryUtils::_generateMethodAnnotations() * - * @method static self PIANO() - * @method static self BASS_DRUM() - * @method static self SNARE() - * @method static self CLICKS_AND_STICKS() - * @method static self DOUBLE_BASS() + * @method static NoteInstrument PIANO() + * @method static NoteInstrument BASS_DRUM() + * @method static NoteInstrument SNARE() + * @method static NoteInstrument CLICKS_AND_STICKS() + * @method static NoteInstrument DOUBLE_BASS() */ final class NoteInstrument{ use EnumTrait {