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.22, 8.5.0 - 8.5.7
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.31, 8.3.0 - 8.3.31
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } } array(0) { }

preferences:
61.09 ms | 1021 KiB | 4 Q