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 |
||
| 16 | class ObjectPropertyGroup extends ActiveRecord |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @inheritdoc |
||
| 20 | */ |
||
| 21 | public static function tableName() |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @inheritdoc |
||
| 28 | */ |
||
| 29 | public function rules() |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @inheritdoc |
||
| 40 | */ |
||
| 41 | View Code Duplication | public function attributeLabels() |
|
| 50 | |||
| 51 | public static function getForModel($model) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return PropertyGroup|null |
||
|
|
|||
| 68 | */ |
||
| 69 | public function getGroup() |
||
| 73 | } |
||
| 74 | ?> |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.