1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
--TEST-- Return value is subclass of return type --FILE-- <?php class foo {} class qux extends foo { public function foo() : foo { return $this; } } $qux = new qux(); var_dump($qux->foo()); --EXPECTF-- object(qux)#%d (%d) { }