for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spiral\Tests\Snapshotter;
use Spiral\Snapshotter\FileHandler\Entities\FileTimestamp;
use Spiral\Snapshotter\Helpers\Names;
use Spiral\Snapshotter\Helpers\Timestamps;
use Spiral\Tests\BaseTest;
class HelpersTest extends BaseTest
{
public function testName()
/** @var Names $names */
$names = $this->container->get(Names::class);
$this->assertEquals('filename', $names->onlyName('filename'));
$this->assertEquals('filename', $names->onlyName('filename/'));
$this->assertEquals('filename', $names->onlyName('some/path/to/filename'));
$this->assertEquals('filename', $names->onlyName('/some/path/to/filename/'));
$this->assertEquals('filename', $names->onlyName('C:\some/path/to/filename'));
$this->assertEquals('filename', $names->onlyName('some\path/to\filename'));
}
public function testTimestamp()
/** @var Timestamps $names */
$names = $this->container->get(Timestamps::class);
$timestamp = new FileTimestamp(new \DateTime(), []);
new \DateTime()
object<DateTime>
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);
$this->assertEquals($timestamp, $names->getTime($timestamp));
$this->assertNotEquals('filename', $names->getTime($timestamp, true));
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: