3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface I { public function dummyMethod(); } class A implements I { public function dummyMethod(): A {} } class B extends A { public function dummyMethod(): B {} } class C implements I { public function dummyMethod(): C {} } (new A())->dummyMethod(); (new B())->dummyMethod(); (new C())->dummyMethod();
Output for 7.2.0 - 7.2.9
Fatal error: Declaration of B::dummyMethod(): B must be compatible with A::dummyMethod(): A in /in/YW8dv on line 11
Process exited with code 255.
Output for 7.0.0 - 7.1.21
Fatal error: Uncaught TypeError: Return value of A::dummyMethod() must be an instance of A, none returned in /in/YW8dv:8 Stack trace: #0 /in/YW8dv(19): A->dummyMethod() #1 {main} thrown in /in/YW8dv on line 8
Process exited with code 255.
Output for hhvm-3.18.5, hhvm-3.22.0
Fatal error: Uncaught TypeError: Value returned from method A::dummyMethod() must be of type A, null given in /in/YW8dv:-1 Stack trace: #0 /in/YW8dv(-1): A->dummyMethod() #1 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.18.4, hhvm-3.19.2 - 3.21.3
Fatal error: Uncaught TypeError: Value returned from method A::dummyMethod() must be of type A, null given in /in/YW8dv:8 Stack trace: #0 /in/YW8dv(19): A->dummyMethod() #1 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/YW8dv on line 8
Process exited with code 255.