1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Common\Annotations; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Allows the reader to be used in-place of Doctrine's reader. |
7
|
|
|
* |
8
|
|
|
* @author Johannes M. Schmitt <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
class IndexedReader implements Reader |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Reader |
14
|
|
|
*/ |
15
|
|
|
private $delegate; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Constructor. |
19
|
|
|
* |
20
|
|
|
* @param Reader $reader |
21
|
|
|
*/ |
22
|
|
|
public function __construct(Reader $reader) |
23
|
|
|
{ |
24
|
|
|
$this->delegate = $reader; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritDoc} |
29
|
|
|
*/ |
30
|
|
|
public function getClassAnnotations(\ReflectionClass $class) |
31
|
|
|
{ |
32
|
|
|
$annotations = []; |
33
|
|
|
foreach ($this->delegate->getClassAnnotations($class) as $annot) { |
34
|
|
|
$annotations[get_class($annot)] = $annot; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
return $annotations; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
*/ |
43
|
|
|
public function getClassAnnotation(\ReflectionClass $class, $annotation) |
44
|
|
|
{ |
45
|
|
|
return $this->delegate->getClassAnnotation($class, $annotation); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* {@inheritDoc} |
50
|
|
|
*/ |
51
|
|
|
public function getMethodAnnotations(\ReflectionMethod $method) |
52
|
|
|
{ |
53
|
|
|
$annotations = []; |
54
|
|
|
foreach ($this->delegate->getMethodAnnotations($method) as $annot) { |
55
|
|
|
$annotations[get_class($annot)] = $annot; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return $annotations; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritDoc} |
63
|
|
|
*/ |
64
|
|
|
public function getMethodAnnotation(\ReflectionMethod $method, $annotation) |
65
|
|
|
{ |
66
|
|
|
return $this->delegate->getMethodAnnotation($method, $annotation); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritDoc} |
71
|
|
|
*/ |
72
|
|
|
public function getPropertyAnnotations(\ReflectionProperty $property) |
73
|
|
|
{ |
74
|
|
|
$annotations = []; |
75
|
|
|
foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { |
76
|
|
|
$annotations[get_class($annot)] = $annot; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $annotations; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritDoc} |
84
|
|
|
*/ |
85
|
|
|
public function getPropertyAnnotation(\ReflectionProperty $property, $annotation) |
86
|
|
|
{ |
87
|
|
|
return $this->delegate->getPropertyAnnotation($property, $annotation); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Proxies all methods to the delegate. |
92
|
|
|
* |
93
|
|
|
* @param string $method |
94
|
|
|
* @param array $args |
95
|
|
|
* |
96
|
|
|
* @return mixed |
97
|
|
|
*/ |
98
|
|
|
public function __call($method, $args) |
99
|
|
|
{ |
100
|
|
|
return call_user_func_array([$this->delegate, $method], $args); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|