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 |
||
| 5 | class MultipleAdvancedModelTransformer extends AdvancedModelTransformer |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * A list of Models to include to the results, even if they are not |
||
| 9 | * specified by the user |
||
| 10 | * |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | private $included = array(); |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Transforms data to an object |
||
| 17 | * |
||
| 18 | * @param string $data |
||
| 19 | * @return \Model[] |
||
| 20 | */ |
||
| 21 | 1 | public function reverseTransform($data) |
|
| 74 | |||
| 75 | /** |
||
| 76 | * Add a model to the list of models that should be included in all cases |
||
| 77 | * |
||
| 78 | * @param \Model $model The model to include |
||
| 79 | * @throws \Exception When a model is of an unsupported type |
||
| 80 | */ |
||
| 81 | 1 | public function addInclude(\Model $model) |
|
| 93 | } |
||
| 94 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.