/** * Registers an instance. * * @param string $key * @param object $instance */ private function registerInstance($key, $instance) { $this->objects[$key] = $instance; $class = get_class($instance); $parents = $this->reflector->getParents($class); foreach ($parents as $parent) { if (isset($this->objects[$parent])) { continue; } if ($this->reflector->isUserDefined($parent)) { $this->objects[$parent] = $instance; } } $interfaces = $this->reflector->getInterfaces($class); foreach ($interfaces as $interface) { if (isset($this->interfaces[$interface])) { continue; } if ($this->reflector->isUserDefined($interface)) { $this->interfaces[$interface] = $class; } } }