3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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";
based on cMcMZ
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught Error: Cannot re-assign $this in /in/WBlGY:14 Stack trace: #0 /in/WBlGY(14): extract(Array) #1 /in/WBlGY(46): foo->getFoo() #2 {main} thrown in /in/WBlGY on line 14
Process exited with code 255.
Output for 5.4.0 - 7.0.20
__get 123