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 |
||
18 | class EmbeddableClassMetadataBinder |
||
19 | { |
||
20 | /** |
||
21 | * @var Mapping\ClassMetadataBuildingContext |
||
22 | */ |
||
23 | private $metadataBuildingContext; |
||
24 | |||
25 | /** |
||
26 | * @var \ReflectionClass |
||
27 | */ |
||
28 | private $reflectionClass; |
||
29 | |||
30 | /** |
||
31 | * [dreaming] One day we would eliminate this and only do: $reflectionClass->getAnnotations() |
||
32 | * |
||
33 | * @var array<string, object> |
||
34 | */ |
||
35 | private $classAnnotations; |
||
36 | |||
37 | /** |
||
38 | * @todo guilhermeblanco This should disappear once we instantiation happens in the Driver |
||
39 | * |
||
40 | * @var Mapping\ClassMetadata |
||
41 | */ |
||
42 | private $classMetadata; |
||
43 | |||
44 | /** |
||
45 | * ComponentMetadataBinder constructor. |
||
46 | * |
||
47 | * @param \ReflectionClass $reflectionClass |
||
48 | * @param array<string, object> $classAnnotations |
||
49 | * @param Mapping\ClassMetadata $classMetadata |
||
50 | * @param Mapping\ClassMetadataBuildingContext $metadataBuildingContext |
||
51 | */ |
||
52 | View Code Duplication | public function __construct( |
|
64 | |||
65 | /** |
||
66 | * @return Mapping\ClassMetadata |
||
67 | */ |
||
68 | public function bind() : Mapping\ClassMetadata |
||
76 | |||
77 | /** |
||
78 | * @param Mapping\ClassMetadata $classMetadata |
||
79 | * @param Annotation\Embeddable $embeddableAnnotation |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | private function processEmbeddableAnnotation( |
||
91 | } |
||
92 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.