3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A {} class B extends A {} class C { public function test() : A { return new A; } } class D extends C { // overriding method C::test() : A public function test() : B // Fatal error due to variance mismatch { return new B; } } ?>
Output for 7.0.0 - 7.0.1
Fatal error: Declaration of D::test(): B must be compatible with C::test(): A in /in/t2fYQ on line 21
Process exited with code 255.
Output for 5.3.21 - 5.6.16
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/t2fYQ on line 8
Process exited with code 255.