- var_dump: documentation ( source)
<?php
class Foo
{
private $bar = 'baz';
}
class Test
{
public function getReader()
{
$reader = function & ($object, $property) {
$value = & Closure::bind(function & () use ($property) {
return $this->$property;
}, $object, $object)->__invoke();
return $value;
};
return $reader;
}
public function doStuff()
{
$reader = $this->getReader();
$foo = new Foo();
$bar = & $reader($foo, 'bar');
$bar = 'tabb';
return $foo;
}
}
$test = new Test();
$foo = $test->doStuff();
var_dump($foo);