dis-bench / src /php /php-src /Zend /tests /enum /case-attributes.phpt
meddyrat's picture
Replace repository contents with the original corrected artifact
1e94262
Raw History Blame Contribute Delete
457 Bytes
--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"
}