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());
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
object(FooChild)#2 (0) { }

preferences:
66.24 ms | 406 KiB | 5 Q