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 |
||
12 | class CopyTest extends \Naneau\FileGen\Test\Generator\TestCase |
||
13 | { |
||
14 | /** |
||
15 | * Test copying |
||
16 | * |
||
17 | * @return void |
||
18 | **/ |
||
19 | public function testCopy() |
||
43 | |||
44 | /** |
||
45 | * Test copy fail |
||
46 | * |
||
47 | * @expectedException Naneau\FileGen\File\Contents\Exception |
||
48 | * @return void |
||
49 | **/ |
||
50 | View Code Duplication | public function testNotExists() |
|
64 | |||
65 | /** |
||
66 | * Test copy fail |
||
67 | * |
||
68 | * @expectedException Naneau\FileGen\File\Contents\Exception |
||
69 | * @return void |
||
70 | **/ |
||
71 | public function testNotReadable() |
||
88 | } |
||
89 |
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: