1 | <?php |
||
31 | trait AnnotationTrait |
||
32 | { |
||
33 | |||
34 | abstract public function getDocComment(); |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | |||
41 | private $useStatementsCache; |
||
42 | |||
43 | /** |
||
44 | * Get an annotation by it literal name. |
||
45 | * |
||
46 | * @param Annotation|null |
||
47 | * @throws MultipleAnnotationException |
||
48 | * @return string |
||
49 | */ |
||
50 | |||
51 | public function getAnnotation($name) |
||
65 | |||
66 | /** |
||
67 | * Get all annotations, or several of then. Note that here annotations can |
||
68 | * have regex on they name. |
||
69 | * |
||
70 | * @param array $names if empty will return all annotations. Can have regex. |
||
71 | * @return array ["AnnotationName" => Annotation] |
||
72 | */ |
||
73 | |||
74 | public function getAnnotations(array $names = array()) |
||
88 | |||
89 | /** |
||
90 | * Check if an annotation exists |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | |||
95 | public function hasAnnotation($name) |
||
99 | |||
100 | /** |
||
101 | * Find all annotations that the name match the $pattern |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | |||
106 | protected function getMatchedAnnotations($pattern) |
||
111 | |||
112 | /** |
||
113 | * Instantiate a new Annotation object, if the annotation has a specific object |
||
114 | * then resolve the name and create it. |
||
115 | * |
||
116 | * @param array $annotation The getMatchedAnnotation annotation return. |
||
117 | * @return Annotation |
||
118 | */ |
||
119 | |||
120 | protected function getAnnotationObject($annotation) |
||
138 | |||
139 | /** |
||
140 | * Get all use statements from the annotated reflection file. |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | |||
145 | protected function getUseStatements() |
||
164 | |||
165 | /** |
||
166 | * Get a fraction of the annotated reflection file. |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | |||
171 | private function getClassFileHeader() |
||
186 | |||
187 | /** |
||
188 | * Resolve annotation name. |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | |||
193 | private function getAnnotationName($name) |
||
202 | |||
203 | } |
||
204 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.