3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooParent {} class FooChild extends FooParent {}; interface BarInterface { public function getProvider(): FooParent; } class BarImplementation { public function getProvider(): FooChild { return new FooChild(); } } $a = new BarImplementation(); var_dump($a->getProvider());

preferences:
24.27 ms | 404 KiB | 5 Q