1--TEST-- 2Resolve attribute names 3--FILE-- 4<?php 5 6namespace { 7 function dump_attributes($attributes) { 8 $arr = []; 9 foreach ($attributes as $attribute) { 10 $arr[] = ['name' => $attribute->getName(), 'args' => $attribute->getArguments()]; 11 } 12 var_dump($arr); 13 } 14} 15 16namespace Doctrine\ORM\Mapping { 17 class Entity { 18 } 19} 20 21namespace Doctrine\ORM\Attributes { 22 class Table { 23 } 24} 25 26namespace Foo { 27 use Doctrine\ORM\Mapping\Entity; 28 use Doctrine\ORM\Mapping as ORM; 29 use Doctrine\ORM\Attributes; 30 31 #[Entity("imported class")] 32 #[ORM\Entity("imported namespace")] 33 #[\Doctrine\ORM\Mapping\Entity("absolute from namespace")] 34 #[\Entity("import absolute from global")] 35 #[Attributes\Table()] 36 function foo() { 37 } 38} 39 40namespace { 41 class Entity {} 42 43 dump_attributes((new ReflectionFunction('Foo\foo'))->getAttributes()); 44} 45?> 46--EXPECT-- 47array(5) { 48 [0]=> 49 array(2) { 50 ["name"]=> 51 string(27) "Doctrine\ORM\Mapping\Entity" 52 ["args"]=> 53 array(1) { 54 [0]=> 55 string(14) "imported class" 56 } 57 } 58 [1]=> 59 array(2) { 60 ["name"]=> 61 string(27) "Doctrine\ORM\Mapping\Entity" 62 ["args"]=> 63 array(1) { 64 [0]=> 65 string(18) "imported namespace" 66 } 67 } 68 [2]=> 69 array(2) { 70 ["name"]=> 71 string(27) "Doctrine\ORM\Mapping\Entity" 72 ["args"]=> 73 array(1) { 74 [0]=> 75 string(23) "absolute from namespace" 76 } 77 } 78 [3]=> 79 array(2) { 80 ["name"]=> 81 string(6) "Entity" 82 ["args"]=> 83 array(1) { 84 [0]=> 85 string(27) "import absolute from global" 86 } 87 } 88 [4]=> 89 array(2) { 90 ["name"]=> 91 string(29) "Doctrine\ORM\Attributes\Table" 92 ["args"]=> 93 array(0) { 94 } 95 } 96} 97