3v4l.org

run code in 200+ php & hhvm versions
<?php spl_autoload_register(function($class) { if ($class === 'A') { class A { public function foo($x): B { return new B; } } } else if ($class === 'B') { class B extends A { public function foo($x): C { return new C; } } } else if ($class === 'C') { class C extends B { } } }); (new C)->foo('blah');
based on 4bHiF
Output for 7.4.0alpha1 - 7.4.0beta4
Output for 7.1.25 - 7.3.8
Fatal error: Declaration of B::foo($x): C must be compatible with A::foo($x): B in /in/AhD6U on line 11
Process exited with code 255.