3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { protected $foo; protected $bar; protected $baz; } $aHydrator = function(array $data) { $this->foo = $data['a']; $this->bar = $data['b']; $this->baz = $data['c']; }; $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); $hydrated = new Foo(); $data = array('a' => 1, 'b' => 2, 'c' => 3); $a = new Foo(); ($aHydrator->bindTo($a, $a))($data); var_dump($hydrated);
based on RjmMa
Output for 7.0.0 - 7.2.0
object(Foo)#2 (3) { ["foo":protected]=> NULL ["bar":protected]=> NULL ["baz":protected]=> NULL }
Output for 5.3.21 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/1fDcg on line 23
Process exited with code 255.