<?php class foo { } class qux { public function foo() : foo { return $this; } } $qux = new qux(); $qux->foo();
<?php interface foo { public function bar() : foo; } class qux implements foo { public function bar() : qux { return $this; } } $qux = new qux(); var_dump($qux->bar());
<?php class foo { } class qux extends foo { public function foo() : foo { return $this; } } $qux = new qux(); var_dump($qux->foo());