class Db {
public function __construct($host, $user, $pass) {}
}
class Gateway
{
public function __construct(Db $db) {}
}
$config = array(
'Db' => array('localhost', 'user', 'pass'),
'Gateway' => array('&Db')
);
$fetchInstance = function($dependency) use ($config) {
static $instances = array();
$reflector = new ReflectionClass($dependency);
$args = array();
foreach ($config[$dependency] as $key => $dependency) {
if (substr($dependency, 0, 1) === '&') {
if (!isset($instances[$dependency])) {