3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {} #[Foo] class Bar {} $reflection = new ReflectionClass(Bar::class); var_dump( $attr = $reflection->getAttributes(), $attr[0]->getName(), $attr[0]->getTarget(), );
Output for 8.4.1 - 8.4.3
array(1) { [0]=> object(ReflectionAttribute)#2 (1) { ["name"]=> string(3) "Foo" } } string(3) "Foo" int(1)
Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } } string(3) "Foo" int(1)

preferences:
56.56 ms | 407 KiB | 5 Q