Exemple #1
0
 protected function createConstructorParameters(Meta\InjectionMetaClass $metaClass, $assistedParams)
 {
     if ($metaClass->hasInjectableConstructor()) {
         return array_map(function ($parameterMeta) use($assistedParams) {
             if ($parameterMeta->isAssisted()) {
                 if (!isset($assistedParams[$parameterMeta->name()])) {
                     if (!$parameterMeta->isOptional()) {
                         throw new Binding\BindingException('Missing assisted parameter "' . $parameterMeta->name() . '"');
                     } else {
                         return $parameterMeta->defaultValue();
                     }
                 }
                 return $assistedParams[$parameterMeta->name()];
             }
             return $this->createParameter($parameterMeta);
         }, $metaClass->injectableConstructor());
     } else {
         return (array) $assistedParams;
     }
 }
 public function testNamedInjection()
 {
     $injectionMetaClass = new InjectionMetaClass('Octahedron\\Pulp\\Test\\Meta\\TestNamedInjectClass', $this->annotationReader);
     $setters = $injectionMetaClass->injectableSetters();
     $this->assertEquals('TestProvider', $setters['testMethod'][0]->type());
 }