public function testDefinition() { $definition = new Definition(); $definition->setClass('Foo'); $definition->setArguments([1, 2, 3]); $this->assertEquals('Foo', $definition->getClass()); $this->assertEquals([1, 2, 3], $definition->getArguments()); }
public function testDefinition() { $definition = new Definition('Bar'); $definition->setClass('Foo'); static::assertEquals('Foo', $definition->getClass()); $arguments = array(1, 2, 3); static::assertFalse($definition->hasArguments()); $definition->setArguments($arguments); static::assertTrue($definition->hasArguments()); static::assertEquals($arguments, $definition->getArguments()); $calls = array(array('method', array(1, 2))); static::assertFalse($definition->hasCalls()); $definition->addCalls($calls); static::assertTrue($definition->hasCalls()); static::assertEquals($calls, $definition->getCalls()); }
public function createInstance(Definition $serviceConf, $container) { // decode the argument list $params = (array) $this->normalize($serviceConf->getArguments(), $container); if ($serviceConf->hasFactory()) { $instance = $this->createFromFactory($serviceConf->getFactory(), $params, $container); } else { $class = new \ReflectionClass($serviceConf->getClass()); // create the instance $instance = $class->newInstanceArgs($params); } return $instance; }