3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { } class UserProvider { public static function getServices() { return ['user']; } public static function user() { return new User(); } } $services = array_map(function($factoryName) { return [UserProvider::class, $factoryName](); }, UserProvider::getServices()); var_dump($services);

preferences:
23.02 ms | 405 KiB | 5 Q