1--TEST-- 2Return type allows self 3--FILE-- 4<?php 5class Foo { 6 public static function getInstance() : self { 7 return new static(); 8 } 9} 10 11class Bar extends Foo {} 12 13var_dump(Foo::getInstance()); 14var_dump(Bar::getInstance()); 15--EXPECTF-- 16object(Foo)#%d (%d) { 17} 18object(Bar)#%d (%d) { 19} 20