3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Garage { public function create():Vehicle; } class CarGarage implements Garage { public function create():Car { return new Car(); } } class Vehicle {} class Car extends Vehicle {} $class = new CarGarage(); var_dump($class->create());
based on hDlob
Output for 7.0.0 - 7.3.1
Fatal error: Declaration of CarGarage::create(): Car must be compatible with Garage::create(): Vehicle in /in/p1m14 on line 6
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/p1m14 on line 3
Process exited with code 255.