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) |
||
86 | |||
87 | /** |
||
88 | * The @description and @desc annotations may be used in |
||
89 | * place of the synopsis (which we call 'description'). |
||
90 | * This is discouraged. |
||
91 | * |
||
92 | * @deprecated |
||
93 | */ |
||
94 | protected function processAlternateDescriptionTag($tag) |
||
98 | |||
99 | /** |
||
100 | * Store the data from a @arg annotation in our argument descriptions. |
||
101 | */ |
||
102 | protected function processArgumentTag($tag) |
||
106 | |||
107 | /** |
||
108 | * Store the data from an @option annotation in our option descriptions. |
||
109 | */ |
||
110 | protected function processOptionTag($tag) |
||
114 | |||
115 | protected function addOptionOrArgumentTag($tag, DefaultsWithDescriptions $set) |
||
125 | |||
126 | /** |
||
127 | * Store the data from a @default annotation in our argument or option store, |
||
128 | * as appropriate. |
||
129 | */ |
||
130 | protected function processDefaultTag($tag) |
||
146 | |||
147 | /** |
||
148 | * Store the data from a @usage annotation in our example usage list. |
||
149 | */ |
||
150 | protected function processUsageTag($tag) |
||
158 | |||
159 | /** |
||
160 | * Process the comma-separated list of aliases |
||
161 | */ |
||
162 | protected function processAliases($tag) |
||
166 | |||
167 | /** |
||
168 | * Store the data from a @param annotation in our argument descriptions. |
||
169 | */ |
||
170 | protected function processParamTag($tag) |
||
180 | |||
181 | /** |
||
182 | * Store the data from a @return annotation in our argument descriptions. |
||
183 | */ |
||
184 | abstract protected function processReturnTag($tag); |
||
185 | |||
186 | protected function interpretDefaultValue($defaultValue) |
||
202 | |||
203 | /** |
||
204 | * Given a docblock description in the form "$variable description", |
||
205 | * return the variable name and description via the 'match' parameter. |
||
206 | */ |
||
207 | protected function pregMatchNameAndDescription($source, &$match) |
||
215 | |||
216 | /** |
||
217 | * Given a list that might be 'a b c' or 'a, b, c' or 'a,b,c', |
||
218 | * convert the data into the last of these forms. |
||
219 | */ |
||
220 | protected static function convertListToCommaSeparated($text) |
||
224 | |||
225 | /** |
||
226 | * Take a multiline description and convert it into a single |
||
227 | * long unbroken line. |
||
228 | */ |
||
229 | protected static function removeLineBreaks($text) |
||
233 | } |
||
234 |