3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $a='data'; protected $b=123; public $c=true; } /** * @author Lisachenko Alexander <lisachenko.it@gmail.com> */ class Hydrator { private function getContext() { return get_object_vars($this); } public function __invoke($object) { static $hydrator = null; if (!$hydrator) { $hydrator = (new ReflectionMethod(__CLASS__, 'getContext'))->getClosure($this); } return $hydrator->bindTo($object, get_class($object))->__invoke($object); } } $test = new Test; $hydrator = new Hydrator(); $data = $hydrator($test); var_dump($data);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Cannot bind method Hydrator::getContext() to object of class Test in /in/BtTRD on line 26 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/BtTRD:26 Stack trace: #0 /in/BtTRD(32): Hydrator->__invoke(Object(Test)) #1 {main} thrown in /in/BtTRD on line 26
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.91 ms | 401 KiB | 8 Q