- var_dump: documentation ( source)
<?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());