3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_mode=1); interface BarInterface { } interface ServerBarInterface { public function doBar(); } interface FooInterface { public function doFoo(BarInterface $bar); } class SomeFoo implements FooInterface { public function doFoo(ServerBarInterface $bar) { $bar->doBar(); } } class RegularBar implements BarInterface {} class ServerBar implements ServerBarInterface { public function doBar() { echo "works"; } } $foo = new SomeFoo; $bar = new RegularBar; $foo->doFoo($bar);
Output for 7.0.0 - 7.2.0
Warning: Unsupported declare 'strict_mode' in /in/M5Buf on line 2 Fatal error: Declaration of SomeFoo::doFoo(ServerBarInterface $bar) must be compatible with FooInterface::doFoo(BarInterface $bar) in /in/M5Buf on line 22
Process exited with code 255.
Output for 5.4.9 - 5.6.28
Warning: Unsupported declare 'strict_mode' in /in/M5Buf on line 2 Fatal error: Declaration of SomeFoo::doFoo() must be compatible with FooInterface::doFoo(BarInterface $bar) in /in/M5Buf on line 23
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Warning: Unsupported declare 'strict_mode' in /in/M5Buf on line 2 Fatal error: Declaration of SomeFoo::doFoo() must be compatible with that of FooInterface::doFoo() in /in/M5Buf on line 23
Process exited with code 255.