Added documentation for RegistryTrait, EnumTrait and CloningRegistryTrait

This commit is contained in:
Dylan K. Taylor 2022-11-30 21:04:17 +00:00
parent 279056fe2f
commit eb62dc3294
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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[]