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 |
||
19 | abstract class LanguageAwareTestCase extends TestCase |
||
20 | { |
||
21 | /** |
||
22 | * Language handler. |
||
23 | * |
||
24 | * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingLanguageHandler |
||
25 | */ |
||
26 | protected $languageHandler; |
||
27 | |||
28 | /** |
||
29 | * Language mask generator. |
||
30 | * |
||
31 | * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator |
||
32 | */ |
||
33 | protected $languageMaskGenerator; |
||
34 | |||
35 | /** |
||
36 | * Returns a language handler mock. |
||
37 | * |
||
38 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler |
||
39 | */ |
||
40 | protected function getLanguageHandler() |
||
48 | |||
49 | /** |
||
50 | * Returns a language mask generator. |
||
51 | * |
||
52 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator |
||
53 | */ |
||
54 | protected function getLanguageMaskGenerator() |
||
64 | |||
65 | /** |
||
66 | * Return definition-based transformation processor instance. |
||
67 | * |
||
68 | * @return Persistence\TransformationProcessor\DefinitionBased |
||
69 | */ |
||
70 | protected function getDefinitionBasedTransformationProcessor() |
||
80 | |||
81 | /** |
||
82 | * @var \eZ\Publish\Core\Search\Common\FieldNameGenerator|\PHPUnit_Framework_MockObject_MockObject |
||
83 | */ |
||
84 | protected $fieldNameGeneratorMock; |
||
85 | |||
86 | /** |
||
87 | * @return \eZ\Publish\Core\Search\Common\FieldNameGenerator|\PHPUnit_Framework_MockObject_MockObject |
||
88 | */ |
||
89 | View Code Duplication | protected function getFieldNameGeneratorMock() |
|
100 | |||
101 | /** |
||
102 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler $contentTypeHandler |
||
103 | * @return \eZ\Publish\Core\Search\Legacy\Content\Mapper\FullTextMapper |
||
104 | */ |
||
105 | protected function getFullTextMapper(Persistence\Legacy\Content\Type\Handler $contentTypeHandler) |
||
112 | |||
113 | /** |
||
114 | * Get FullText search configuration. |
||
115 | */ |
||
116 | protected function getFullTextSearchConfiguration() |
||
157 | } |
||
158 |
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..