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 |
||
| 10 | abstract class HtmlSemNavElement extends HtmlSemCollection { |
||
| 11 | /** |
||
| 12 | * @var string the root site |
||
| 13 | */ |
||
| 14 | protected $root; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var String the html attribute which contains the elements url. default : data-ajax |
||
| 18 | */ |
||
| 19 | protected $attr; |
||
| 20 | |||
| 21 | protected $_contentSeparator=""; |
||
| 22 | |||
| 23 | |||
| 24 | public function __construct($identifier,$tagName,$baseClass){ |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Associate an ajax get to the elements, displayed in $targetSelector |
||
| 32 | * $attr member is used to build each element url |
||
| 33 | * @param string $targetSelector the target of the get |
||
| 34 | * @param string $attr the html attribute used to build the elements url |
||
|
|
|||
| 35 | * @return HtmlNavElement |
||
| 36 | */ |
||
| 37 | public function autoGetOnClick($targetSelector){ |
||
| 40 | |||
| 41 | public function contentAsString(){ |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Generate the jquery script to set the elements to the HtmlNavElement |
||
| 47 | * @param JsUtils $jsUtils |
||
| 48 | */ |
||
| 49 | public function jsSetContent(JsUtils $jsUtils){ |
||
| 52 | |||
| 53 | public function getRoot() { |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Define the html attribute for each element url in ajax |
||
| 66 | * @param string $attr html attribute |
||
| 67 | * @return HtmlNavElement |
||
| 68 | */ |
||
| 69 | public function setAttr($attr) { |
||
| 73 | |||
| 74 | View Code Duplication | public function __call($method, $args) { |
|
| 82 | |||
| 83 | public abstract function fromDispatcher($dispatcher,$startIndex=0); |
||
| 84 | |||
| 85 | |||
| 86 | public function setContentSeparator($contentSeparator) { |
||
| 90 | |||
| 91 | |||
| 92 | } |
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.