1 | <?php |
||
11 | final class AnnotationParser |
||
12 | { |
||
13 | private const REGEX = '\s+(.*?)\s*(\$.+?)?\s*\z'; |
||
14 | |||
15 | /** |
||
16 | * @param string $comment |
||
17 | * |
||
18 | * @return VariableAnnotation[] |
||
19 | * @throws Exception |
||
20 | */ |
||
21 | public function parseParameterAnnotations(string $comment): array |
||
25 | |||
26 | /** |
||
27 | * @param string $comment |
||
28 | * |
||
29 | * @return VariableAnnotation[] |
||
30 | * @throws Exception |
||
31 | */ |
||
32 | public function parseVariableAnnotations(string $comment): array |
||
36 | |||
37 | /** |
||
38 | * @param string $comment |
||
39 | * |
||
40 | * @return VariableAnnotation[] |
||
41 | * @throws Exception |
||
42 | */ |
||
43 | public function parsePropertyAnnotations(string $comment): array |
||
47 | |||
48 | /** |
||
49 | * @param string $annotation |
||
50 | * @param string $comment |
||
51 | * |
||
52 | * @return VariableAnnotation[] |
||
53 | * @throws Exception |
||
54 | */ |
||
55 | private function parseAnnotations(string $annotation, string $comment): array |
||
69 | |||
70 | /** |
||
71 | * @param string $annotation |
||
72 | * @param string $line |
||
73 | * |
||
74 | * @return VariableAnnotation|null |
||
75 | * @throws Exception |
||
76 | */ |
||
77 | private function parseAnnotation(string $annotation, string $line): ?VariableAnnotation |
||
88 | |||
89 | /** |
||
90 | * @param array $matches |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | private function parseAnnotationMatch(array $matches): array |
||
107 | } |
||
108 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.