/** * @param string $className * @param array $constructorArguments * @return object */ public function getInstanceOfClass($className, array $constructorArguments = array()) { $fullFactoryClassName = $this->getFullFactoryClassName($className); $factoryClassName = $this->getFactoryClassName($className); if ($this->factoryClassExists($fullFactoryClassName, $factoryClassName)) { return $fullFactoryClassName::getInstance($constructorArguments); } return parent::getInstanceOfClass($className, $constructorArguments); }
public function testInjectionLoopDetectionNoRecA() { $config = new Configuration(); $dic = new DependencyInjectionContainer($config); $this->assertInstanceOf(InjectionLoopDetectionTest_NoRecA::class, $dic->getInstanceOfClass(InjectionLoopDetectionTest_NoRecA::class)); }
public function testGetInstanceOfClassWhereDefaultImplementedByIsNotTheFirstItem() { $dic = new DependencyInjectionContainer(); $class = $dic->getInstanceOfClass('issueImplementedByOrder\\name\\B'); $this->assertInstanceOf('issueImplementedByOrder\\name\\D', $class); }