<?php class test { public function a() { return new static(); } public function b() { return 'hello'; } } echo test::a()->b(); // hello