3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Base {} class Sub extends Base{} class NoRelation {} abstract class I { abstract public function foo(Sub $x); } class CorrectImplementor extends I { public function foo(Base $x) {} // Should be ok } class IncorrectImplementor extends I { public function foo(NoRelation $x) {} // Should be disallowed }
based on 5QNhb
Output for 7.0.0 - 7.0.2
Fatal error: Declaration of CorrectImplementor::foo(Base $x) must be compatible with I::foo(Sub $x) in /in/osXn2 on line 13
Process exited with code 255.
Output for 5.4.12 - 5.6.17
Fatal error: Declaration of CorrectImplementor::foo() must be compatible with I::foo(Sub $x) in /in/osXn2 on line 13
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/osXn2 on line 13
Process exited with code 255.