1 | <?php |
||
12 | abstract class AbstractCommandDocBlockParser |
||
13 | { |
||
14 | /** |
||
15 | * @var CommandInfo |
||
16 | */ |
||
17 | protected $commandInfo; |
||
18 | |||
19 | /** |
||
20 | * @var \ReflectionMethod |
||
21 | */ |
||
22 | protected $reflection; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $tagProcessors = [ |
||
28 | 'command' => 'processCommandTag', |
||
29 | 'name' => 'processCommandTag', |
||
30 | 'arg' => 'processArgumentTag', |
||
31 | 'param' => 'processParamTag', |
||
32 | 'return' => 'processReturnTag', |
||
33 | 'option' => 'processOptionTag', |
||
34 | 'default' => 'processDefaultTag', |
||
35 | 'aliases' => 'processAliases', |
||
36 | 'usage' => 'processUsageTag', |
||
37 | 'description' => 'processAlternateDescriptionTag', |
||
38 | 'desc' => 'processAlternateDescriptionTag', |
||
39 | ]; |
||
40 | |||
41 | public function __construct(CommandInfo $commandInfo, \ReflectionMethod $reflection) |
||
46 | |||
47 | protected function processAllTags($phpdoc) |
||
58 | |||
59 | abstract protected function getTagContents($tag); |
||
60 | |||
61 | /** |
||
62 | * Parse the docBlock comment for this command, and set the |
||
63 | * fields of this class with the data thereby obtained. |
||
64 | */ |
||
65 | abstract public function parse(); |
||
66 | |||
67 | /** |
||
68 | * Save any tag that we do not explicitly recognize in the |
||
69 | * 'otherAnnotations' map. |
||
70 | */ |
||
71 | protected function processGenericTag($tag) |
||
75 | |||
76 | /** |
||
77 | * Set the name of the command from a @command or @name annotation. |
||
78 | */ |
||
79 | protected function processCommandTag($tag) |
||
87 | |||
88 | /** |
||
89 | * The @description and @desc annotations may be used in |
||
90 | * place of the synopsis (which we call 'description'). |
||
91 | * This is discouraged. |
||
92 | * |
||
93 | * @deprecated |
||
94 | */ |
||
95 | protected function processAlternateDescriptionTag($tag) |
||
99 | |||
100 | /** |
||
101 | * Store the data from a @arg annotation in our argument descriptions. |
||
102 | */ |
||
103 | protected function processArgumentTag($tag) |
||
110 | |||
111 | /** |
||
112 | * Store the data from an @option annotation in our option descriptions. |
||
113 | */ |
||
114 | protected function processOptionTag($tag) |
||
121 | |||
122 | protected function addOptionOrArgumentTag($tag, DefaultsWithDescriptions $set, $nameAndDescription) |
||
129 | |||
130 | /** |
||
131 | * Store the data from a @default annotation in our argument or option store, |
||
132 | * as appropriate. |
||
133 | */ |
||
134 | protected function processDefaultTag($tag) |
||
150 | |||
151 | /** |
||
152 | * Store the data from a @usage annotation in our example usage list. |
||
153 | */ |
||
154 | protected function processUsageTag($tag) |
||
162 | |||
163 | /** |
||
164 | * Process the comma-separated list of aliases |
||
165 | */ |
||
166 | protected function processAliases($tag) |
||
170 | |||
171 | /** |
||
172 | * Store the data from a @param annotation in our argument descriptions. |
||
173 | */ |
||
174 | protected function processParamTag($tag) |
||
184 | |||
185 | /** |
||
186 | * Store the data from a @return annotation in our argument descriptions. |
||
187 | */ |
||
188 | abstract protected function processReturnTag($tag); |
||
189 | |||
190 | protected function interpretDefaultValue($defaultValue) |
||
206 | |||
207 | /** |
||
208 | * Given a docblock description in the form "$variable description", |
||
209 | * return the variable name and description via the 'match' parameter. |
||
210 | */ |
||
211 | protected function pregMatchNameAndDescription($source, &$match) |
||
219 | |||
220 | /** |
||
221 | * Given a docblock description in the form "$variable description", |
||
222 | * return the variable name and description via the 'match' parameter. |
||
223 | */ |
||
224 | protected function pregMatchOptionNameAndDescription($source, &$match) |
||
234 | |||
235 | /** |
||
236 | * Given a list that might be 'a b c' or 'a, b, c' or 'a,b,c', |
||
237 | * convert the data into the last of these forms. |
||
238 | */ |
||
239 | protected static function convertListToCommaSeparated($text) |
||
243 | |||
244 | /** |
||
245 | * Take a multiline description and convert it into a single |
||
246 | * long unbroken line. |
||
247 | */ |
||
248 | protected static function removeLineBreaks($text) |
||
252 | } |
||
253 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.