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