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 |
||
| 10 | class Leads extends PaginatedListResource |
||
| 11 | { |
||
| 12 | /** {@inheritdoc} */ |
||
| 13 | protected function getEndpoint() |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param int $page |
||
| 20 | * @param LeadsSortBy $sortBy |
||
|
|
|||
| 21 | * |
||
| 22 | * @return ResourceCollection |
||
| 23 | */ |
||
| 24 | View Code Duplication | public function all($page = 1, LeadsSortBy $sortBy = null) |
|
| 34 | |||
| 35 | /** {@inheritdoc} */ |
||
| 36 | public function create(DetachedResource $resource, array $fieldNames = [], $useKey = true) |
||
| 61 | } |
||
| 62 |
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.