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 |
||
| 14 | class DoctrineEventProxy |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var EntityCollection |
||
| 18 | */ |
||
| 19 | protected $loaders; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var EntityCollection |
||
| 23 | */ |
||
| 24 | protected $unsupportedClasses; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Construct. |
||
| 28 | */ |
||
| 29 | public function __construct() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Register a loader for given entity class. |
||
| 37 | * |
||
| 38 | * @param string $entityClass |
||
| 39 | * @param string $loader |
||
| 40 | */ |
||
| 41 | public function registerDoctrineLazyLoader($entityClass, LazyLoaderInterface $loader) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Retrieve a lazy loader for given class (or not). |
||
| 56 | * |
||
| 57 | * @param object $entityClass |
||
|
|
|||
| 58 | * |
||
| 59 | * @return |
||
| 60 | */ |
||
| 61 | private function getLoader($entity) |
||
| 81 | |||
| 82 | /** |
||
| 83 | * "postLoad" Doctrine event handler, notify loaders if define for given event related entity. |
||
| 84 | * |
||
| 85 | * @param LifecycleEventArgs $event |
||
| 86 | */ |
||
| 87 | public function postLoad(LifecycleEventArgs $event) |
||
| 115 | } |
||
| 116 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.