[php-src] Issue #7729: enums
| From: | noreply@php.net | Date: | Tue, 07 Dec 2021 10:07:51 +0000 |
| Subject: | [php-src] Issue #7729: enums | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238233@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7729
Author: richirm77
### Description
Hello!
There seems to be no way to get the string representation of an instance of an enum, except with
var_export().
```php
enum Foo: string {
case Bar = 'bar';
case Baz = 'baz';
}
$bar = Foo::Bar;
$bar_string = var_export($bar, true);
```
Also, what if I want to find out the backing value of an enum variable?
```php
$backing_value = (new \ReflectionEnumBackedCase($bar, ???))->getBackingValue();
```
Any ideas?