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 | trait LazyLoaderTrait |
||
11 | { |
||
12 | /** |
||
13 | * Hydrate lazy loads delegate into given Collectionnable, if enabled and if |
||
14 | * entity supports it. |
||
15 | * |
||
16 | * @param LazyPropertiesInterface $object (not hinted to help notation and custom exception) |
||
|
|||
17 | * |
||
18 | * @return LazyPropertiesInterface |
||
19 | */ |
||
20 | private function loadDelegates($entity) |
||
56 | } |
||
57 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.