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 | class HtmlLabel extends HtmlSemDoubleElement { |
||
12 | use LabeledIconTrait; |
||
13 | public function __construct($identifier,$caption="",$tagName="div") { |
||
14 | parent::__construct($identifier,$tagName,"ui label"); |
||
15 | $this->content=$caption; |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * @param string $side |
||
|
|||
20 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
21 | */ |
||
22 | public function setPointing($value=Direction::NONE){ |
||
23 | return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $side |
||
28 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
29 | */ |
||
30 | public function toCorner($side="left"){ |
||
33 | |||
34 | /** |
||
35 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
36 | */ |
||
37 | public function asTag(){ |
||
40 | |||
41 | /** |
||
42 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
43 | */ |
||
44 | public function asLink(){ |
||
47 | |||
48 | public function setBasic(){ |
||
51 | |||
52 | /** |
||
53 | * Adds an image to emphasize |
||
54 | * @param string $src |
||
55 | * @param string $alt |
||
56 | * @param string $before |
||
57 | * @return \Ajax\semantic\html\elements\HtmlLabel |
||
58 | */ |
||
59 | public function addImage($src,$alt="",$before=true){ |
||
63 | |||
64 | /** |
||
65 | * @param string $detail |
||
66 | * @return \Ajax\common\html\HtmlDoubleElement |
||
67 | */ |
||
68 | View Code Duplication | public function addDetail($detail){ |
|
75 | } |
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
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.