thunderer /
Platenum
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | namespace Thunder\Platenum\Enum; |
||
| 4 | |||
| 5 | use Thunder\Platenum\Exception\PlatenumException; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @template TMember |
||
| 9 | * @template TValue |
||
| 10 | * |
||
| 11 | * @author Tomasz Kowalczyk <[email protected]> |
||
| 12 | 1 | */ |
|
| 13 | trait StaticEnumTrait |
||
| 14 | 12 | { |
|
| 15 | /** @use EnumTrait<TMember,TValue> */ |
||
| 16 | 12 | use EnumTrait; |
|
| 17 | |||
| 18 | private static function resolve(): array |
||
| 19 | 12 | { |
|
| 20 | 1 | $class = static::class; |
|
| 21 | // reflection instead of property_exists because of PHP 7.4 bug #78632 |
||
| 22 | // @see https://bugs.php.net/bug.php?id=78632 |
||
| 23 | 11 | if(false === (new \ReflectionClass($class))->hasProperty('mapping')) { |
|
| 24 | throw PlatenumException::fromMissingMappingProperty($class); |
||
| 25 | } |
||
| 26 | |||
| 27 | return static::$mapping; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 28 | } |
||
| 29 | } |
||
| 30 |