- extract: documentation ( source)
<?php
class foo
{
private $proxy;
public function __construct(self $proxy = null)
{
$this->proxy = $proxy ?: $this;
}
public function getFoo()
{
extract(['this' => $this->proxy]);
return $this->foo;
}
}
class fooProxy extends foo
{
protected $proxy;
private $foo;
public function __construct($foo)
{
$this->foo = $foo;
}
public function __set($name, $value)
{
echo __FUNCTION__, "\n";
$this->$name = $value;
}
public function __get($name)
{
echo __FUNCTION__, "\n";
return $this->$name;
}
}
$p = new fooProxy(123);
echo $p->getFoo();
echo "\n";