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 |
||
42 | class PageIntegrationTest extends BaseIntegrationTest |
||
43 | { |
||
44 | /** |
||
45 | * Get name of tested field type. |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | public function getTypeName() |
||
53 | |||
54 | /** |
||
55 | * Get handler with required custom field types registered. |
||
56 | * |
||
57 | * @return \eZ\Publish\SPI\Persistence\Handler |
||
58 | */ |
||
59 | public function getCustomHandler() |
||
70 | |||
71 | /** |
||
72 | * Returns the FieldTypeConstraints to be used to create a field definition |
||
73 | * of the FieldType under test. |
||
74 | * |
||
75 | * @return \eZ\Publish\SPI\Persistence\Content\FieldTypeConstraints |
||
76 | */ |
||
77 | public function getTypeConstraints() |
||
81 | |||
82 | /** |
||
83 | * Get field definition data values. |
||
84 | * |
||
85 | * This is a PHPUnit data provider |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | public function getFieldDefinitionData() |
||
108 | |||
109 | /** |
||
110 | * Get initial field value. |
||
111 | * |
||
112 | * @return \eZ\Publish\SPI\Persistence\Content\FieldValue |
||
113 | */ |
||
114 | public function getInitialValue() |
||
124 | |||
125 | /** |
||
126 | * Get update field value. |
||
127 | * |
||
128 | * Use to update the field |
||
129 | * |
||
130 | * @return \eZ\Publish\SPI\Persistence\Content\FieldValue |
||
131 | */ |
||
132 | public function getUpdatedValue() |
||
142 | |||
143 | /** |
||
144 | * Create a dummy page object. |
||
145 | * |
||
146 | * @return Page |
||
147 | */ |
||
148 | View Code Duplication | protected function getPage() |
|
168 | } |
||
169 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: