3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { #[Test] public function foo() {} } class B extends A { public function foo() {} } var_dump((new ReflectionMethod('A', 'foo'))->getAttributes()); var_dump((new ReflectionMethod('B', 'foo'))->getAttributes());
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(1) { [0]=> object(ReflectionAttribute)#2 (1) { ["name"]=> string(4) "Test" } } array(0) { }
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } } array(0) { }

preferences:
72.69 ms | 990 KiB | 4 Q