- array_map: documentation ( source)
- var_dump: documentation ( source)
<?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);