- var_export: documentation ( source)
<?php declare(strict_types = 1);
class A{
protected $stuff;
function __construct(int $foo){
$this->stuff = $foo;
}
function getStuff(): int{
return $this->stuff;
}
static function __set_state($data){
return new A($data['stuff']);
}
}
$x = new A(10);
eval('$y = ' . var_export($x, true) . ';');
$y->getStuff();