for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class TocifierTest extends PHPUnit_Framework_TestCase
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
public function testProcess()
$tocifier = new Tocifier(1234);
$this->assertFalse($tocifier->process());
$tocifier = new Tocifier('');
$tocifier = new Tocifier(null);
$tocifier = new Tocifier(array('1234'));
array('1234')
array<integer,string,{"0":"string"}>
string
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:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$tocifier = new Tocifier('1234');
$this->assertTrue($tocifier->process());
}
public function testHtml()
$tocifier = new Tocifier(file_get_contents(__DIR__ . '/test1'));
$this->assertEquals($tocifier->getHtml(), '');
$this->assertStringEqualsFile(__DIR__ . '/html1', $tocifier->getHtml());
public function testTOC()
$this->assertEquals($tocifier->getTOC(), array());
$this->assertNotNull($tocifier->getTOC());
ob_start();
$tocifier->dumpTOC();
$returned = ob_get_clean();
$this->assertStringEqualsFile(__DIR__ . '/toc1', $returned);
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.