3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_CLASS_CONSTANT)] class TestAttribute { public function __construct(public string $value) { } } enum TestNum { #[TestAttribute('alpha value')] case ALPHA; #[TestAttribute('beta value')] case BETA; } $obj = TestNum::ALPHA; $reflection = new ReflectionClass($obj); $classAttributes = $reflection->getAttributes(TestAttribute::class); var_dump($classAttributes);

preferences:
62.29 ms | 1241 KiB | 5 Q