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 |
||
| 17 | class XmlWriter extends Xml |
||
| 18 | { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * XMLWriter handler |
||
| 22 | * {@inheritdoc} |
||
| 23 | */ |
||
| 24 | public function encode(array $data, $rootNode='root') |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Array to XMLWriter |
||
| 40 | * |
||
| 41 | * @param \XmlWriter $xml |
||
|
|
|||
| 42 | * @param array $array |
||
| 43 | * @see https://bugs.php.net/bug.php?id=63589 |
||
| 44 | */ |
||
| 45 | View Code Duplication | protected function arrayToXmlWriter(\XmlWriter $x, array $array) |
|
| 64 | |||
| 65 | } |
||
| 66 |
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.