3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A {} class B extends A {} class C extends B {} interface InterfaceTest { public function foo(B $p); } abstract class AbstractTest { public abstract function foo(B $p); } // class TestAbstractContravariance extends AbstractTest { // public function foo(A $p) {} // } //class TestAbstractCovariance extends AbstractTest { // public function foo(C $p) {} //} class TestInterfaceContravariance implements InterfaceTest { public function foo(A $p) {} } class TestInterfaceCovariance implements InterfaceTest { public function foo(C $p) {} }
based on gcKTm
Output for 7.0.0 - 7.2.0
Fatal error: Declaration of TestInterfaceContravariance::foo(A $p) must be compatible with InterfaceTest::foo(B $p) in /in/21fYt on line 18
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Declaration of TestInterfaceContravariance::foo() must be compatible with InterfaceTest::foo(B $p) in /in/21fYt on line 19
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Fatal error: Declaration of TestInterfaceContravariance::foo() must be compatible with that of InterfaceTest::foo() in /in/21fYt on line 19
Process exited with code 255.