--TEST-- Attributes can be placed on all supported elements. --FILE-- 1; $ref = new \ReflectionClass(Foo::class); $sources = [ $ref, $ref->getReflectionConstant('FOO'), $ref->getProperty('x'), $ref->getMethod('foo'), $ref->getMethod('foo')->getParameters()[0], $ref->getMethod('foo')->getParameters()[1], new \ReflectionObject($object), new \ReflectionFunction('f1'), new \ReflectionFunction($f2), new \ReflectionFunction($f3) ]; foreach ($sources as $r) { $attr = $r->getAttributes(); var_dump(get_class($r), count($attr)); foreach ($attr as $a) { var_dump($a->getName(), $a->getArguments()); } echo "\n"; } ?> --EXPECT-- string(15) "ReflectionClass" int(1) string(2) "A1" array(1) { [0]=> int(1) } string(23) "ReflectionClassConstant" int(1) string(2) "A1" array(1) { [0]=> int(2) } string(18) "ReflectionProperty" int(1) string(2) "A1" array(1) { [0]=> int(3) } string(16) "ReflectionMethod" int(1) string(2) "A1" array(1) { [0]=> int(4) } string(19) "ReflectionParameter" int(1) string(2) "A1" array(1) { [0]=> int(5) } string(19) "ReflectionParameter" int(1) string(2) "A1" array(1) { [0]=> int(6) } string(16) "ReflectionObject" int(1) string(2) "A1" array(1) { [0]=> int(7) } string(18) "ReflectionFunction" int(1) string(2) "A1" array(1) { [0]=> int(8) } string(18) "ReflectionFunction" int(1) string(2) "A1" array(1) { [0]=> int(9) } string(18) "ReflectionFunction" int(1) string(2) "A1" array(1) { [0]=> int(10) }