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 |
||
| 27 | class CounterRepository extends RepositoryCounter implements UserCounter |
||
| 28 | { |
||
| 29 | public function __construct(UserInterface $model) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param int $deleted |
||
| 36 | * |
||
| 37 | * @return int |
||
| 38 | */ |
||
| 39 | public function countNotDeleted() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param int $deleted |
||
| 46 | * |
||
| 47 | * @return int |
||
| 48 | */ |
||
| 49 | public function countDeleted() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Count number of created issues in a project. |
||
| 56 | * |
||
| 57 | * @param int $projectId |
||
| 58 | * |
||
| 59 | * @return int |
||
| 60 | */ |
||
| 61 | View Code Duplication | public function createdIssuesCount($projectId = 0) |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Returns all projects with open issue count. |
||
| 75 | * |
||
| 76 | * @param int $status |
||
| 77 | * |
||
| 78 | * @return Builder|Relations\BelongsToMany |
||
| 79 | */ |
||
| 80 | View Code Duplication | public function projectsWithCountOpenIssues($status = Project::STATUS_OPEN) |
|
| 90 | |||
| 91 | /** |
||
| 92 | * Count number of archived projects. |
||
| 93 | * |
||
| 94 | * @return int |
||
| 95 | */ |
||
| 96 | public function countProjectsByStatus($status) |
||
| 104 | } |
||
| 105 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..