Simplify getting 'enum' constants
This commit is contained in:
parent
0da8d12758
commit
23c88b7dad
@ -3,6 +3,7 @@
|
|||||||
namespace Kilo;
|
namespace Kilo;
|
||||||
|
|
||||||
use FFI;
|
use FFI;
|
||||||
|
use ReflectionClass;
|
||||||
|
|
||||||
trait MagicProperties {
|
trait MagicProperties {
|
||||||
abstract public function __get(string $name);
|
abstract public function __get(string $name);
|
||||||
@ -37,15 +38,7 @@ class Key {
|
|||||||
|
|
||||||
public static function getConstList(): array
|
public static function getConstList(): array
|
||||||
{
|
{
|
||||||
static $self;
|
return (new ReflectionClass(static::class))->getConstants();
|
||||||
|
|
||||||
if ($self === NULL)
|
|
||||||
{
|
|
||||||
$class = static::class;
|
|
||||||
$self = new $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new \ReflectionClass($self))->getConstants();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user