3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class UserController { public function getUser($name): User { if(! $user = $this->repo->findByName($name)){ throw UserNotCreatedYetException; } } public function register(Request $req) { try { $user = $this->getUser($name); } catch(UserNotCreatedYetException $e) { $user = new User( $req->get('username') ); } } }
based on Rb72e
Output for hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/ndfTh on line 5
Process exited with code 255.