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 |
||
| 15 | class Cv extends AbstractRepository |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Look for an drafted Document of a given user |
||
| 19 | * |
||
| 20 | * @param $user |
||
| 21 | * @return CvEntity|null |
||
|
|
|||
| 22 | */ |
||
| 23 | View Code Duplication | public function findDraft($user) |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param Application $application |
||
| 45 | * @param UserInterface $user |
||
| 46 | * @return CvEntity |
||
| 47 | * @since 0.26 |
||
| 48 | */ |
||
| 49 | public function createFromApplication(Application $application, UserInterface $user) |
||
| 90 | } |
||
| 91 |
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.