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