Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class CommandDocBlockParser2 extends AbstractCommandDocBlockParser |
||
16 | { |
||
17 | /** |
||
18 | * Parse the docBlock comment for this command, and set the |
||
19 | * fields of this class with the data thereby obtained. |
||
20 | */ |
||
21 | public function parse() |
||
39 | |||
40 | /** |
||
41 | * Save any tag that we do not explicitly recognize in the |
||
42 | * 'otherAnnotations' map. |
||
43 | */ |
||
44 | protected function processGenericTag($tag) |
||
48 | |||
49 | /** |
||
50 | * Set the name of the command from a @command or @name annotation. |
||
51 | */ |
||
52 | protected function processCommandTag($tag) |
||
59 | |||
60 | /** |
||
61 | * The @description and @desc annotations may be used in |
||
62 | * place of the synopsis (which we call 'description'). |
||
63 | * This is discouraged. |
||
64 | * |
||
65 | * @deprecated |
||
66 | */ |
||
67 | protected function processAlternateDescriptionTag($tag) |
||
71 | |||
72 | /** |
||
73 | * Store the data from a @arg annotation in our argument descriptions. |
||
74 | */ |
||
75 | protected function processArgumentTag($tag) |
||
79 | |||
80 | /** |
||
81 | * Store the data from a @param annotation in our argument descriptions. |
||
82 | */ |
||
83 | View Code Duplication | protected function processParamTag($tag) |
|
96 | |||
97 | /** |
||
98 | * Store the data from a @return annotation in our argument descriptions. |
||
99 | */ |
||
100 | protected function processReturnTag($tag) |
||
107 | |||
108 | /** |
||
109 | * Store the data from an @option annotation in our option descriptions. |
||
110 | */ |
||
111 | protected function processOptionTag($tag) |
||
115 | |||
116 | View Code Duplication | protected function addOptionOrArgumentTag($tag, DefaultsWithDescriptions $set) |
|
126 | |||
127 | /** |
||
128 | * Store the data from a @default annotation in our argument or option store, |
||
129 | * as appropriate. |
||
130 | */ |
||
131 | View Code Duplication | protected function processDefaultTag($tag) |
|
147 | |||
148 | /** |
||
149 | * Process the comma-separated list of aliases |
||
150 | */ |
||
151 | protected function processAliases($tag) |
||
155 | |||
156 | /** |
||
157 | * Store the data from a @usage annotation in our example usage list. |
||
158 | */ |
||
159 | View Code Duplication | protected function processUsageTag($tag) |
|
167 | } |
||
168 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.