3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X{ public $prop = 42; function test(){ return new static('anything you want to pass to a constructor which is not here because I am lazy'); } } $x = new X(); var_dump($x->test());

preferences:
28.86 ms | 402 KiB | 5 Q