3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeParent { public function foo(): self { return $this; } } final class SomeChild extends SomeParent { public function foo(): SomeChild { return $this; } } var_dump((new SomeChild())->foo());
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
object(SomeChild)#1 (0) { }

preferences:
48.89 ms | 406 KiB | 5 Q