Beispiel #1
0
 public function createDependency(Injector $injector, $assistedParams = null, $isOptional = false)
 {
     if ($this->isBoundToImplementation()) {
         return $injector->getInstance($this->implementation, $assistedParams, $isOptional);
     }
     if ($this->isBoundToProvider()) {
         // TODO: inject the parameters instead of the injector itself
         if (is_callable($this->provider)) {
             return call_user_func($this->provider, $injector);
         }
         $injector->injectMembers($this->provider);
         return $this->provider->get();
     }
     if ($this->isBoundToInstance()) {
         return $this->instance;
     }
     return $injector->createInstance($this->interface, $assistedParams, $isOptional);
 }
Beispiel #2
0
 public function testMultipleAssistedParameterDefaults()
 {
     $injector = new Injector($this->binderMock, $this->annotationReader);
     $param = 'two';
     $object = $injector->createInstance('Octahedron\\Pulp\\Test\\TestMultipleAssistedParamDefaultInject', ['assistedTwo' => $param]);
     $this->assertSame('test', $object->assisted);
     $this->assertSame($param, $object->assistedTwo);
 }