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