- var_dump: documentation ( source)
<?php
class Bar
{
private $baz = 'tab';
}
class Foo extends Bar
{
private $baz = 'baz';
public function __construct()
{
$this->accessor = function () { return $this->baz; };
$this->writer = function ($bar) { $this->baz = $bar; };
}
}
$accessor = function () { return $this->baz; };
$foo = new Foo();
$bar = new Bar();
$accessor = Closure::bind($accessor, $bar, 'Bar');
var_dump($accessor());
$writer = Closure::bind($foo->writer, $bar, 'Bar');
$writer('taz');
var_dump($bar);