for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Thunder\Serializard\Tests;
use Thunder\Serializard\NormalizerContext\ParentNormalizerContext;
/**
* @author Tomasz Kowalczyk <[email protected]>
*/
final class NormalizerContextTest extends AbstractTestCase
{
public function testParentNormalizerContext()
$ctx = new ParentNormalizerContext();
$this->assertSame(0, $ctx->getLevel());
$this->assertNull(null, $ctx->getParent());
$ctx->getParent()
object
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->assertNull(null, $ctx->getFormat());
$this->assertNull(null, $ctx->getRoot());
$ctx->getRoot()
$object = new \stdClass();
$ctx = $ctx->withRoot($object)->withFormat('json');
$ctx = $ctx->withParent($object);
$this->assertSame(1, $ctx->getLevel());
$this->assertSame($object, $ctx->getParent());
$this->assertSame($object, $ctx->getRoot());
$this->assertSame('json', $ctx->getFormat());
}
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: