3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $config = ['legendaryName' => 'legendary_name']; $data = ['legendary_name' => 'The Hammer']; class Warrior { use DbHydrate; private $legendaryName; } trait DbHydrate { public function hydrate($config, $data) { foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $this->{$attributeName} = $data[$column]; } throw \Exception('The property %s does not exists in %s', $attributeName, self::class); } } } $legendaryWarrior = new Warrior; $legendaryWarrior->hydrate($config, $data); var_dump($legendaryWarrior); $config = ['classicalName' => 'classical_name']; $data = ['classical_name' => 'John']; $testWarrior = new Warrior; $testWarrior->hydrate($config, $data); var_dump($testWarrior);
based on DI57T
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Call to undefined function Exception() in /in/ZpPJX:21 Stack trace: #0 /in/ZpPJX(27): Warrior->hydrate(Array, Array) #1 {main} thrown in /in/ZpPJX on line 21
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Call to undefined function Exception() in /in/ZpPJX:-1 Stack trace: #0 /in/ZpPJX(-1): Warrior->hydrate() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Call to undefined function Exception() in /in/ZpPJX:21 Stack trace: #0 /in/ZpPJX(27): Warrior->hydrate() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined function Exception() in /in/ZpPJX on line 21
Process exited with code 255.