3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $thing; public function __construct($thing) { $this->thing = $thing; } public static function create() { return new static('foo'); } } class B extends A { protected $another; public function getAnother() { return $this->another; } public static function create() { $instance = parent::create(); $instance->another = 'bar'; return $instance; } } var_dump(B::create()->getAnother());

preferences:
47.82 ms | 402 KiB | 5 Q