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 |
||
3 | namespace eNTiDi\Autotoc\Tests; |
||
4 | |||
5 | use eNTiDi\Autotoc\Tocifier; |
||
6 | use PHPUnit_Framework_TestCase; |
||
7 | |||
8 | class TocifierTest extends PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | public function testProcess() |
||
27 | |||
28 | public function testPrependAnchor() |
||
37 | |||
38 | public function testSetId() |
||
47 | |||
48 | View Code Duplication | public function testTOC() |
|
60 | |||
61 | View Code Duplication | public function testDataHideFromTOC() |
|
1 ignored issue
–
show
|
|||
62 | { |
||
63 | $tocifier = new Tocifier(file_get_contents(__DIR__ . '/test2')); |
||
64 | $this->assertEquals('', $tocifier->getHtml()); |
||
65 | $this->assertTrue($tocifier->process()); |
||
66 | |||
67 | // Check the augmented HTML is equal to the original one |
||
68 | $this->assertStringEqualsFile(__DIR__ . '/test2', $tocifier->getHtml()); |
||
69 | |||
70 | ob_start(); |
||
76 |
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: