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 HorizontalFormErrorRender extends AbstractErrorRender implements ErrorRendererInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @param DOMElement $div |
||
|
|
|||
| 19 | * @param FieldInterface $field |
||
| 20 | * @return DOMElement |
||
| 21 | */ |
||
| 22 | 1 | public function render(FieldInterface $field) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @param DOMElement $helpBlock |
||
| 41 | * @param FieldInterface $field |
||
| 42 | * @return DOMElement |
||
| 43 | */ |
||
| 44 | 1 | View Code Duplication | private function addCustomErrorMessage(DOMElement $helpBlock, FieldInterface $field) |
| 51 | |||
| 52 | /** |
||
| 53 | * @param DOMElement $helpBlock |
||
| 54 | * @param FieldInterface $field |
||
| 55 | * @return DOMElement] |
||
| 56 | */ |
||
| 57 | 1 | View Code Duplication | private function addErrorMessages(DOMElement $helpBlock, FieldInterface $field) |
| 66 | |||
| 67 | /** |
||
| 68 | * @param DOMElement $helpBlock |
||
| 69 | * @param $message |
||
| 70 | * @return DOMElement |
||
| 71 | */ |
||
| 72 | 1 | View Code Duplication | private function appendMessage(DOMElement $helpBlock, $message) |
| 80 | |||
| 81 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.