Access private members of parent classes; playing with the scopes:
<?PHP
class Grandparents{ private $__status1 = 'married'; }
class Parents extends Grandparents{ private $__status2 = 'divorced'; }
class Me extends Parents{ private $__status3 = 'single'; }
$status1_3 = function()
{
$this->__status1 = 'happy';
$this->__status2 = 'happy';
$this->__status3 = 'happy';
};
$status1_2 = function()
{
$this->__status1 = 'happy';
$this->__status2 = 'happy';
};
$c = $status1_3->bindTo($R = new Me, Parents::class);
$d = $status1_2->bindTo($R = new Me, Parents::class);
$d();
var_dump($R);
$e = $status1_3->bindTo($R = new Me, Grandparents::class);
$f = $status1_2->bindTo($R = new Me, Grandparents::class);
$f();
var_dump($R);
?>
Clear the stack trace:
<?PHP
use Exception;
use ReflectionException;
$c = function()
{
$this->trace = [];
};
$c = $c->bindTo($R = new ReflectionException, Exception::class);
$c();
try
{
throw $R;
}
catch(ReflectionException $R)
{
var_dump($R->getTrace());
}
?>