|
PocketMine-MP 5.39.1 git-1be3f83620f013523bb4d35535c6c0f842b54a6a
|
Inheritance diagram for pocketmine\utils\RegistrySource:
Collaboration diagram for pocketmine\utils\RegistrySource:Public Member Functions | |
| getAllDeclarations () | |
| getAllValues () | |
| getTargetClassDocComment () | |
| getTargetClassName () | |
Static Public Member Functions | |
| static | preprocessMember (object $member) |
Protected Member Functions | |
| registerDelayed (string $name, \Closure $valueFactory) | |
| registerValue (string $name, mixed $value) | |
| setup () | |
Extend this class to define source values for a generated registry class. A registry class has generated functions that simulate object constants.
The values are defined in the self::setup() function. The generated class's name is defined in self::getTargetClassName(). The generated class will belong to the same namespace as your source class.
The generated class will call your source class at runtime, so both the source and generated class must be included in the build.
To create a registry, simply extend this class and implement the abstract methods. Then, run the registry-interface.php script in the build folder to generate the accessor class.
This supersedes the older RegistryTrait, which is slower and less robust than this newer approach, and also required patching source classes. This approach allows the generated code to be fully separate from the source code.
@phpstan-template TMember of object
Definition at line 51 of file RegistrySource.php.
|
final |
Definition at line 67 of file RegistrySource.php.
|
final |
Definition at line 179 of file RegistrySource.php.
|
final |
Definition at line 165 of file RegistrySource.php.
| pocketmine\utils\RegistrySource::getTargetClassDocComment | ( | ) |
Returns information to be prepended to the doc comment on the generated class. Do not include any PHPDoc formatting (e.g. comment tags) in here.
Reimplemented in pocketmine\block\VanillaBlocksInputs, pocketmine\entity\effect\VanillaEffectsInputs, pocketmine\item\enchantment\VanillaEnchantmentsInputs, pocketmine\item\VanillaArmorMaterialsInputs, and pocketmine\item\VanillaItemsInputs.
Definition at line 84 of file RegistrySource.php.
|
abstract |
Returns the short name (without namespace) of the class to be generated. The generated class will have the same namespace as your source class.
Reimplemented in pocketmine\block\VanillaBlocksInputs, pocketmine\entity\effect\VanillaEffectsInputs, pocketmine\item\enchantment\VanillaEnchantmentsInputs, pocketmine\item\VanillaArmorMaterialsInputs, and pocketmine\item\VanillaItemsInputs.
|
static |
Override this if you need to, for example, clone a registry member before returning it to the caller
@phpstan-template TParam of object
@phpstan-param TParam $member @phpstan-return TParam
Definition at line 119 of file RegistrySource.php.
|
finalprotected |
Adds a value using a callback, which will be invoked when the registry is first accessed at runtime. The type of the generated registry function will be the same as that of the provided closure.
Use this if the value's initialization depends on generated registry code (i.e. it accesses another registry member, either in this registry or another).
Note: A return type MUST be set on the provided closure, or an error will be thrown.
@phpstan-param \Closure(string $name) : TMember $valueFactory
Definition at line 151 of file RegistrySource.php.
|
finalprotected |
Adds a plain value to the registry source. You can use this if the value does not depend on any other generated registry code. The type of the generated registry function will be inferred from the value provided.
@phpstan-param TMember $value @phpstan-return TMember
Definition at line 131 of file RegistrySource.php.
|
abstractprotected |
Implement this to add members to the registry.
Reimplemented in pocketmine\block\VanillaBlocksInputs, pocketmine\entity\effect\VanillaEffectsInputs, pocketmine\item\enchantment\VanillaEnchantmentsInputs, pocketmine\item\VanillaArmorMaterialsInputs, and pocketmine\item\VanillaItemsInputs.