private function injectDependencies(InstanceRepository $repository, $instance) { $annotations = $this->provider->getMetadata($instance); $class = new ReflectionClass($instance); $properties = $class->getProperties(); foreach ($properties as $property) { $annotation = Arrays::getValue($annotations, $property->getName()); if ($annotation) { $binder = $this->bindings->getBinder($annotation['className'], $annotation['name']); $dependencyInstance = $repository->getInstance($this, $binder); $property->setAccessible(true); $property->setValue($instance, $dependencyInstance); } } }
public function getInstance($className, $name = '') { $binder = $this->bindings->getBinder($className, $name); return $this->repository->getInstance($this->factory, $binder); }