Beispiel #1
0
 public function bindInterceptor(Method $method, $index)
 {
     $matchers = $method->getAnnotation("Spot\\Inject\\Intercept")->getMatchers();
     $key = Key::ofType("Spot\\Aspect\\Intercept\\MethodInterceptor");
     $dependencies = [];
     foreach ($method->getParameters() as $parameter) {
         $dependencies[] = $this->bindParameter($parameter);
     }
     $binding = new ProviderMethodBinding($key, $index, $method, $dependencies);
     $this->pointCuts->put(new PointCut($matchers, $binding));
 }
Beispiel #2
0
 public static function ofParameter(Parameter $parameter)
 {
     $qualifier = $parameter->getAnnotation("Spot\\Inject\\Qualifier");
     if ($class = $parameter->getClass()) {
         return Key::ofType($class->name, $qualifier);
     }
     if (!$qualifier) {
         throw new ConfigurationException("Parameter \${$parameter->name} in " . $parameter->getDeclaringClass()->name . "::" . $parameter->getDeclaringFunction()->name . " is unbindable " . "because it's not type-hinted nor annotated with Qualifier annotation");
     }
     if ($parameter->isArray()) {
         return Key::ofCollection($qualifier);
     }
     return Key::ofConstant($qualifier);
 }
Beispiel #3
0
 public function __construct()
 {
     parent::__construct(Key::ofType("Spot\\Inject\\Injector"));
 }
Beispiel #4
0
 public function __construct(Type $type, array $dependencies)
 {
     parent::__construct(Key::ofType($type->name));
     $this->type = $type;
     $this->dependencies = $dependencies;
 }
Beispiel #5
0
 function getInstance($type)
 {
     return $this->get(Key::ofType($type));
 }