- var_dump: documentation ( source)
<?php
declare(strict_types=1);
class Foo {
private $x;
public function setX($x) : Foo
{
$this->x = $x;
return $this;
}
public function getX()
{
return $this->x;
}
}
function test($class)
{
$obj = new $class();
if (is_object($obj)) {
return $obj;
}
return null;
}
$x = test('Fo')->setX('test');
var_dump($x->getX());