Is it possible to access enumerations properties dynamically?
Here is what I tried and the error I got.
Access to undeclared static property ExampleEnum::$id
enum ExampleEnum
{
case _1;
case _2;
public function getIt(): string
{
return match ($this) {
ExampleEnum::_1 => 'foo',
ExampleEnum::_2 => 'bar',
};
}
}
$id = "_1";
ExampleEnum::$id->getIt();