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.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } } string(3) "Foo" int(1)

preferences:
46.67 ms | 406 KiB | 5 Q