3v4l.org

run code in 300+ 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.14
array(1) { [0]=> object(ReflectionAttribute)#2 (1) { ["name"]=> string(4) "Test" } } array(0) { }
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } } array(0) { }

preferences:
69.23 ms | 407 KiB | 5 Q