3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Foo { abstract protected static function things(); protected $t; protected function __construct($t) { $this->t = $t; } public function getT() { return $this->t; } public static function all() { return array_map(function($t) { return new static($t); }, static::things()); } } class Bar extends Foo { protected static function things() { return [10, 20, 30]; } } $bars = Bar::all(); foreach ($bars as $bar) { echo $bar->getT()."\n"; }

preferences:
40.53 ms | 402 KiB | 5 Q