File size: 457 Bytes
1e94262 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | --TEST--
Enum case attributes
--FILE--
<?php
#[Attribute(Attribute::TARGET_CLASS_CONSTANT)]
class EnumCaseAttribute {
public function __construct(
public string $value,
) {}
}
enum Foo {
#[EnumCaseAttribute('Bar')]
case Bar;
}
var_dump((new \ReflectionClassConstant(Foo::class, 'Bar'))->getAttributes(EnumCaseAttribute::class)[0]->newInstance());
?>
--EXPECT--
object(EnumCaseAttribute)#1 (1) {
["value"]=>
string(3) "Bar"
}
|