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 |
||
9 | class CurrencyTest extends TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @var PHPUnit_Framework_MockObject_MockObject |
||
13 | */ |
||
14 | private $currencyBundle; |
||
15 | |||
16 | /** |
||
17 | * @var Currency |
||
18 | */ |
||
19 | private $currency; |
||
20 | |||
21 | protected function setUp() |
||
27 | |||
28 | public function testDefaultCurrency() |
||
32 | |||
33 | View Code Duplication | public function testDefaultCurrencySymbol() |
|
43 | |||
44 | View Code Duplication | public function testCurrencySymbol() |
|
54 | |||
55 | View Code Duplication | public function testDefaultCurrencyName() |
|
65 | |||
66 | View Code Duplication | public function testCurrencyName() |
|
76 | } |
||
77 |
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: