3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $foo; public static function create($foo) { $new = new static(); $new->setFoo($foo); return $new; } protected function setFoo($foo) { $this->foo = $foo; } public function getFoo() { return $this->foo; } } $a = A::create('asdf'); var_dump($a->getFoo());

preferences:
58.25 ms | 402 KiB | 5 Q