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 |
||
| 11 | abstract class HtmlSemNavElement extends HtmlSemCollection { |
||
| 12 | /** |
||
| 13 | * @var string the root site |
||
| 14 | */ |
||
| 15 | protected $root; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var String the html attribute which contains the elements url. default : data-ajax |
||
| 19 | */ |
||
| 20 | protected $attr; |
||
| 21 | |||
| 22 | protected $_contentSeparator=""; |
||
| 23 | |||
| 24 | |||
| 25 | public function __construct($identifier,$tagName,$baseClass){ |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Associate an ajax get to the elements, displayed in $targetSelector |
||
| 33 | * $attr member is used to build each element url |
||
| 34 | * @param string $targetSelector the target of the get |
||
| 35 | * @param string $attr the html attribute used to build the elements url |
||
|
|
|||
| 36 | * @return HtmlNavElement |
||
| 37 | */ |
||
| 38 | public function autoGetOnClick($targetSelector){ |
||
| 41 | |||
| 42 | public function contentAsString(){ |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Generate the jquery script to set the elements to the HtmlNavElement |
||
| 48 | * @param JsUtils $jsUtils |
||
| 49 | */ |
||
| 50 | public function jsSetContent(JsUtils $jsUtils){ |
||
| 53 | |||
| 54 | public function getRoot() { |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Define the html attribute for each element url in ajax |
||
| 67 | * @param string $attr html attribute |
||
| 68 | * @return HtmlNavElement |
||
| 69 | */ |
||
| 70 | public function setAttr($attr) { |
||
| 74 | |||
| 75 | View Code Duplication | public function __call($method, $args) { |
|
| 83 | |||
| 84 | public abstract function fromDispatcher($dispatcher,$startIndex=0); |
||
| 85 | |||
| 86 | |||
| 87 | public function setContentDivider($divider,$index=NULL) { |
||
| 91 | |||
| 92 | public function setIconContentDivider($iconContentDivider,$index=NULL) { |
||
| 96 | |||
| 97 | protected function setDivider($divider,$index){ |
||
| 107 | |||
| 108 | protected function getContentDivider($index){ |
||
| 114 | |||
| 115 | |||
| 116 | } |
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.