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 |
||
15 | class EncoderTest extends \PHPUnit_Framework_TestCase |
||
16 | { |
||
17 | /** |
||
18 | * @param string $data |
||
19 | * @param array $source |
||
20 | * |
||
21 | * @test |
||
22 | * @dataProvider testSetProvider |
||
23 | */ |
||
24 | public function willDecodeTestCasesFromJwtDotIo($source, $data) |
||
29 | |||
30 | /** |
||
31 | * @test |
||
32 | * @expectedException \RuntimeException |
||
33 | */ |
||
34 | public function willThrowExceptionWhenJsonDecodeFails() |
||
39 | |||
40 | /** |
||
41 | * @see http://jwt.io/ |
||
42 | * @return array |
||
43 | */ |
||
44 | View Code Duplication | public static function testSetProvider() |
|
65 | } |
||
66 |
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: