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)); }
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); }
public function __construct() { parent::__construct(Key::ofType("Spot\\Inject\\Injector")); }
public function __construct(Type $type, array $dependencies) { parent::__construct(Key::ofType($type->name)); $this->type = $type; $this->dependencies = $dependencies; }
function getInstance($type) { return $this->get(Key::ofType($type)); }