Chris@0
|
1 <?php
|
Chris@0
|
2 /*
|
Chris@0
|
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
Chris@0
|
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
Chris@0
|
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
Chris@0
|
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
Chris@0
|
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
Chris@0
|
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
Chris@0
|
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
Chris@0
|
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
Chris@0
|
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
Chris@0
|
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
Chris@0
|
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Chris@0
|
14 *
|
Chris@0
|
15 * This software consists of voluntary contributions made by many individuals
|
Chris@0
|
16 * and is licensed under the MIT license. For more information, see
|
Chris@0
|
17 * <http://www.doctrine-project.org>.
|
Chris@0
|
18 */
|
Chris@0
|
19
|
Chris@0
|
20 namespace Doctrine\Common\Annotations;
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Allows the reader to be used in-place of Doctrine's reader.
|
Chris@0
|
24 *
|
Chris@0
|
25 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
Chris@0
|
26 */
|
Chris@0
|
27 class IndexedReader implements Reader
|
Chris@0
|
28 {
|
Chris@0
|
29 /**
|
Chris@0
|
30 * @var Reader
|
Chris@0
|
31 */
|
Chris@0
|
32 private $delegate;
|
Chris@0
|
33
|
Chris@0
|
34 /**
|
Chris@0
|
35 * Constructor.
|
Chris@0
|
36 *
|
Chris@0
|
37 * @param Reader $reader
|
Chris@0
|
38 */
|
Chris@0
|
39 public function __construct(Reader $reader)
|
Chris@0
|
40 {
|
Chris@0
|
41 $this->delegate = $reader;
|
Chris@0
|
42 }
|
Chris@0
|
43
|
Chris@0
|
44 /**
|
Chris@0
|
45 * {@inheritDoc}
|
Chris@0
|
46 */
|
Chris@0
|
47 public function getClassAnnotations(\ReflectionClass $class)
|
Chris@0
|
48 {
|
Chris@0
|
49 $annotations = array();
|
Chris@0
|
50 foreach ($this->delegate->getClassAnnotations($class) as $annot) {
|
Chris@0
|
51 $annotations[get_class($annot)] = $annot;
|
Chris@0
|
52 }
|
Chris@0
|
53
|
Chris@0
|
54 return $annotations;
|
Chris@0
|
55 }
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * {@inheritDoc}
|
Chris@0
|
59 */
|
Chris@0
|
60 public function getClassAnnotation(\ReflectionClass $class, $annotation)
|
Chris@0
|
61 {
|
Chris@0
|
62 return $this->delegate->getClassAnnotation($class, $annotation);
|
Chris@0
|
63 }
|
Chris@0
|
64
|
Chris@0
|
65 /**
|
Chris@0
|
66 * {@inheritDoc}
|
Chris@0
|
67 */
|
Chris@0
|
68 public function getMethodAnnotations(\ReflectionMethod $method)
|
Chris@0
|
69 {
|
Chris@0
|
70 $annotations = array();
|
Chris@0
|
71 foreach ($this->delegate->getMethodAnnotations($method) as $annot) {
|
Chris@0
|
72 $annotations[get_class($annot)] = $annot;
|
Chris@0
|
73 }
|
Chris@0
|
74
|
Chris@0
|
75 return $annotations;
|
Chris@0
|
76 }
|
Chris@0
|
77
|
Chris@0
|
78 /**
|
Chris@0
|
79 * {@inheritDoc}
|
Chris@0
|
80 */
|
Chris@0
|
81 public function getMethodAnnotation(\ReflectionMethod $method, $annotation)
|
Chris@0
|
82 {
|
Chris@0
|
83 return $this->delegate->getMethodAnnotation($method, $annotation);
|
Chris@0
|
84 }
|
Chris@0
|
85
|
Chris@0
|
86 /**
|
Chris@0
|
87 * {@inheritDoc}
|
Chris@0
|
88 */
|
Chris@0
|
89 public function getPropertyAnnotations(\ReflectionProperty $property)
|
Chris@0
|
90 {
|
Chris@0
|
91 $annotations = array();
|
Chris@0
|
92 foreach ($this->delegate->getPropertyAnnotations($property) as $annot) {
|
Chris@0
|
93 $annotations[get_class($annot)] = $annot;
|
Chris@0
|
94 }
|
Chris@0
|
95
|
Chris@0
|
96 return $annotations;
|
Chris@0
|
97 }
|
Chris@0
|
98
|
Chris@0
|
99 /**
|
Chris@0
|
100 * {@inheritDoc}
|
Chris@0
|
101 */
|
Chris@0
|
102 public function getPropertyAnnotation(\ReflectionProperty $property, $annotation)
|
Chris@0
|
103 {
|
Chris@0
|
104 return $this->delegate->getPropertyAnnotation($property, $annotation);
|
Chris@0
|
105 }
|
Chris@0
|
106
|
Chris@0
|
107 /**
|
Chris@0
|
108 * Proxies all methods to the delegate.
|
Chris@0
|
109 *
|
Chris@0
|
110 * @param string $method
|
Chris@0
|
111 * @param array $args
|
Chris@0
|
112 *
|
Chris@0
|
113 * @return mixed
|
Chris@0
|
114 */
|
Chris@0
|
115 public function __call($method, $args)
|
Chris@0
|
116 {
|
Chris@0
|
117 return call_user_func_array(array($this->delegate, $method), $args);
|
Chris@0
|
118 }
|
Chris@0
|
119 }
|