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 | /** |
||
48 | * Parse the docBlock comment for this command, and set the |
||
49 | * fields of this class with the data thereby obtained. |
||
50 | */ |
||
51 | abstract public function parse(); |
||
52 | |||
53 | /** |
||
54 | * Save any tag that we do not explicitly recognize in the |
||
55 | * 'otherAnnotations' map. |
||
56 | */ |
||
57 | abstract protected function processGenericTag($tag); |
||
58 | |||
59 | /** |
||
60 | * Set the name of the command from a @command or @name annotation. |
||
61 | */ |
||
62 | abstract protected function processCommandTag($tag); |
||
63 | |||
64 | /** |
||
65 | * The @description and @desc annotations may be used in |
||
66 | * place of the synopsis (which we call 'description'). |
||
67 | * This is discouraged. |
||
68 | * |
||
69 | * @deprecated |
||
70 | */ |
||
71 | abstract protected function processAlternateDescriptionTag($tag); |
||
72 | |||
73 | /** |
||
74 | * Store the data from a @arg annotation in our argument descriptions. |
||
75 | */ |
||
76 | abstract protected function processArgumentTag($tag); |
||
77 | |||
78 | /** |
||
79 | * Store the data from a @param annotation in our argument descriptions. |
||
80 | */ |
||
81 | abstract protected function processParamTag($tag); |
||
82 | |||
83 | /** |
||
84 | * Store the data from a @return annotation in our argument descriptions. |
||
85 | */ |
||
86 | abstract protected function processReturnTag($tag); |
||
87 | |||
88 | /** |
||
89 | * Store the data from an @option annotation in our option descriptions. |
||
90 | */ |
||
91 | abstract protected function processOptionTag($tag); |
||
92 | |||
93 | /** |
||
94 | * Store the data from a @default annotation in our argument or option store, |
||
95 | * as appropriate. |
||
96 | */ |
||
97 | abstract protected function processDefaultTag($tag); |
||
98 | |||
99 | /** |
||
100 | * Process the comma-separated list of aliases |
||
101 | */ |
||
102 | abstract protected function processAliases($tag); |
||
103 | |||
104 | /** |
||
105 | * Store the data from a @usage annotation in our example usage list. |
||
106 | */ |
||
107 | abstract protected function processUsageTag($tag); |
||
108 | |||
109 | protected function interpretDefaultValue($defaultValue) |
||
125 | |||
126 | /** |
||
127 | * Given a docblock description in the form "$variable description", |
||
128 | * return the variable name and description via the 'match' parameter. |
||
129 | */ |
||
130 | protected function pregMatchNameAndDescription($source, &$match) |
||
138 | |||
139 | /** |
||
140 | * Given a list that might be 'a b c' or 'a, b, c' or 'a,b,c', |
||
141 | * convert the data into the last of these forms. |
||
142 | */ |
||
143 | protected static function convertListToCommaSeparated($text) |
||
147 | |||
148 | /** |
||
149 | * Take a multiline description and convert it into a single |
||
150 | * long unbroken line. |
||
151 | */ |
||
152 | protected static function removeLineBreaks($text) |
||
156 | } |
||
157 |