3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $proxy; public function __construct(self $proxy = null) { $this->proxy = $proxy ?: $this; } public function getFoo() { extract(['this' => $this->proxy]); echo get_class($this); $f = function () { return $this->foo; }; return $f(); } } class fooProxy extends foo { private $foo; public function __construct($foo) { $this->foo = $foo; parent::__construct($this); } public function __set($name, $value) { echo __FUNCTION__, "\n"; $this->$name = $value; } public function __get($name) { echo __FUNCTION__, "\n"; return $this->$name; } } $p = new foo(new fooProxy(123)); echo $p->getFoo(); echo "\n";

preferences:
51.69 ms | 402 KiB | 5 Q