3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Base {} class Sub extends Base{} class NoRelation {} interface I { public function foo(Sub $x); } class CorrectImplementor implements I { public function foo(Base $x) {} // Should be ok } class IncorrectImplementor implements I { public function foo(NoRelation $x) {} // Should be disallowed }
based on nBbjW
Output for 7.0.0 - 7.2.0
Fatal error: Declaration of CorrectImplementor::foo(Base $x) must be compatible with I::foo(Sub $x) in /in/5QNhb on line 11
Process exited with code 255.
Output for 5.4.12 - 5.6.28
Fatal error: Declaration of CorrectImplementor::foo() must be compatible with I::foo(Sub $x) in /in/5QNhb on line 11
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Fatal error: Declaration of CorrectImplementor::foo() must be compatible with that of I::foo() in /in/5QNhb on line 11
Process exited with code 255.