3v4l.org

run code in 300+ 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:
23.78 ms | 404 KiB | 5 Q