From eb62dc32948870333ce18c5f642273bf70f1b198 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 30 Nov 2022 21:04:17 +0000 Subject: [PATCH] Added documentation for RegistryTrait, EnumTrait and CloningRegistryTrait --- src/utils/CloningRegistryTrait.php | 4 ++++ src/utils/EnumTrait.php | 7 +++++++ src/utils/RegistryTrait.php | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/src/utils/CloningRegistryTrait.php b/src/utils/CloningRegistryTrait.php index c69b38d7d..d160b1f45 100644 --- a/src/utils/CloningRegistryTrait.php +++ b/src/utils/CloningRegistryTrait.php @@ -23,6 +23,10 @@ declare(strict_types=1); namespace pocketmine\utils; +/** + * This trait offers the same functionality as RegistryTrait, but also clones any returned objects to prevent outside + * modification. + */ trait CloningRegistryTrait{ use RegistryTrait; diff --git a/src/utils/EnumTrait.php b/src/utils/EnumTrait.php index c9d24e0fc..ba0a4fcf2 100644 --- a/src/utils/EnumTrait.php +++ b/src/utils/EnumTrait.php @@ -23,6 +23,13 @@ declare(strict_types=1); namespace pocketmine\utils; +/** + * This trait allows a class to simulate a Java-style enum. Members are exposed as static methods and handled via + * __callStatic(). + * + * Classes using this trait need to include \@method tags in their class docblock for every enum member. + * Alternatively, just put \@generate-registry-docblock in the docblock and run tools/generate-registry-annotations.php + */ trait EnumTrait{ use RegistryTrait; use NotCloneable; diff --git a/src/utils/RegistryTrait.php b/src/utils/RegistryTrait.php index 776980599..f8ffc1143 100644 --- a/src/utils/RegistryTrait.php +++ b/src/utils/RegistryTrait.php @@ -28,6 +28,13 @@ use function count; use function mb_strtoupper; use function preg_match; +/** + * This trait allows a class to simulate object class constants, since PHP doesn't currently support this. + * These faux constants are exposed in static class methods, which are handled using __callStatic(). + * + * Classes using this trait need to include \@method tags in their class docblock for every faux constant. + * Alternatively, just put \@generate-registry-docblock in the docblock and run tools/generate-registry-annotations.php + */ trait RegistryTrait{ /** * @var object[]