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 |
||
| 21 | class GroupKeyword extends Component |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * The expression that is used for grouping. |
||
| 25 | * |
||
| 26 | * @var Expression |
||
| 27 | */ |
||
| 28 | public $expr; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Constructor. |
||
| 32 | * |
||
| 33 | * @param Expression $expr the expression that we are sorting by |
||
|
|
|||
| 34 | */ |
||
| 35 | 4 | public function __construct($expr = null) |
|
| 39 | |||
| 40 | /** |
||
| 41 | * @param Parser $parser the parser that serves as context |
||
| 42 | * @param TokensList $list the list of tokens that are being parsed |
||
| 43 | * @param array $options parameters for parsing |
||
| 44 | * |
||
| 45 | * @return GroupKeyword[] |
||
| 46 | */ |
||
| 47 | 3 | View Code Duplication | public static function parse(Parser $parser, TokensList $list, array $options = array()) |
| 116 | |||
| 117 | /** |
||
| 118 | * @param GroupKeyword|GroupKeyword[] $component the component to be built |
||
| 119 | * @param array $options parameters for building |
||
| 120 | * |
||
| 121 | * @return string |
||
| 122 | */ |
||
| 123 | 3 | public static function build($component, array $options = array()) |
|
| 132 | } |
||
| 133 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.