3v4l.org

run code in 500+ PHP versions simultaneously
<?php class XABC { function foo() { // static does not apply to self $f = static function () : self { // __CLASS__ is preserved in the closure echo __CLASS__.PHP_EOL; return new self(); }; return $f; } } var_dump((new xabc)->foo()());

preferences:
67.59 ms | 848 KiB | 5 Q