(PHP 8 >= 8.1.0)
ReflectionEnum::isBacked — 检测 Enum 是否为回退(Backed)Enum
此函数没有参数。
示例 #1 ReflectionEnum::isBacked() 示例
<?php
enum Suit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
enum BackedSuit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
var_dump((new ReflectionEnum(Suit::class))->isBacked());
var_dump((new ReflectionEnum(BackedSuit::class))->isBacked());
?>
以上示例会输出:
bool(false) bool(true)