3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { } class Bar { const SOMECLASS = 'Foo'; protected $instance; public function __construct() { $instance = static::SOMECLASS; $this->instance = new $instance; } } var_dump(new Bar);

preferences:
48.31 ms | 402 KiB | 5 Q