1--TEST-- 2Attributes can be grouped 3--FILE-- 4<?php 5 6#[A1(1), A1(2), A2(3)] 7class Foo 8{ 9} 10 11#[ 12 A1(1), 13 A1(2), 14 A2(3) 15] 16function foo() {} 17 18#[A1, A1, A2] 19function bar() {} 20 21$sources = [ 22 new \ReflectionClass(Foo::class), 23 new \ReflectionFunction('foo'), 24 new \ReflectionFunction('bar'), 25]; 26 27foreach ($sources as $ref) { 28 $attr = $ref->getAttributes(); 29 var_dump(get_class($ref), count($attr)); 30 31 foreach ($attr as $a) { 32 printf("%s(%s)\n", $a->getName(), implode(", ", $a->getArguments())); 33 } 34 35 echo "\n"; 36} 37?> 38--EXPECT-- 39string(15) "ReflectionClass" 40int(3) 41A1(1) 42A1(2) 43A2(3) 44 45string(18) "ReflectionFunction" 46int(3) 47A1(1) 48A1(2) 49A2(3) 50 51string(18) "ReflectionFunction" 52int(3) 53A1() 54A1() 55A2() 56