diff options
author | Ilija Tovilo <ilija.tovilo@me.com> | 2020-06-10 23:10:18 +0200 |
---|---|---|
committer | Ilija Tovilo <ilija.tovilo@me.com> | 2021-03-17 19:08:03 +0100 |
commit | 269c8dac1d56ee85d71ae94d9b28dd7d8e8de7b7 (patch) | |
tree | 810ac41b2157ff4e8063f9696f97e1a9d77837c4 /ext/reflection/php_reflection.stub.php | |
parent | a6fc427b8c51015c16541c112a26dd06bd75e99e (diff) | |
download | php-git-269c8dac1d56ee85d71ae94d9b28dd7d8e8de7b7.tar.gz |
Implement enums
RFC: https://wiki.php.net/rfc/enumerations
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Closes GH-6489.
Diffstat (limited to 'ext/reflection/php_reflection.stub.php')
-rw-r--r-- | ext/reflection/php_reflection.stub.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index 9287ae7e9c..e9815558d6 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -298,6 +298,8 @@ class ReflectionClass implements Reflector /** @return bool */ public function isTrait() {} + public function isEnum(): bool {} + /** @return bool */ public function isAbstract() {} @@ -479,6 +481,8 @@ class ReflectionClassConstant implements Reflector /** @return ReflectionAttribute[] */ public function getAttributes(?string $name = null, int $flags = 0): array {} + + public function isEnumCase(): bool {} } class ReflectionParameter implements Reflector @@ -683,3 +687,36 @@ final class ReflectionAttribute private function __construct() {} } + +final class ReflectionEnum extends ReflectionClass +{ + public function __construct(object|string $objectOrClass) {} + + public function hasCase(string $name): bool {} + + public function getCase(string $name): ReflectionEnumUnitCase {} + + /** @return ReflectionEnumUnitCase[] */ + public function getCases(): array {} + + public function isBacked(): bool {} + + public function getBackingType(): ReflectionType|null {} +} + +class ReflectionEnumUnitCase extends ReflectionClassConstant +{ + public function __construct(object|string $class, string $constant) {} + + public function getEnum(): ReflectionEnum {} + + /** @implementation-alias ReflectionClassConstant::getValue */ + public function getValue(): UnitEnum {} +} + +final class ReflectionEnumBackedCase extends ReflectionEnumUnitCase +{ + public function __construct(object|string $class, string $constant) {} + + public function getBackingValue(): int|string {} +} |