3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait Newable { public static function new() { return new static(); } } class Foo { use Newable; public function meth() : self { return $this; } } var_dump(Foo::new()->meth());

preferences:
52.21 ms | 1956 KiB | 5 Q