3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait HydrateBehaviour { public static function hydrate($other) { $new = new self(); foreach ($other as $k => $v) { $new->{$k} = $v; } return $new; } } class Entity { use HydrateBehaviour; private $ololo; private $foo; private $bar; public function out() { echo $this->ololo, $this->foo, $this->bar; } } $en = Entity::hydrate(['ololo' => 1, 'foo' => 2]); $en->out();
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
12