Exemple #1
0
 public function check(Type $type)
 {
     foreach ($type->getMethods(Method::IS_PUBLIC) as $method) {
         if ($this->pointCuts->matches($method)) {
             return true;
         }
     }
     return false;
 }
Exemple #2
0
 public function bind(Type $module, $index)
 {
     foreach ($module->getMethods() as $method) {
         if ($method->isAnnotatedWith("Spot\\Inject\\Provides")) {
             $this->bindMethod($method, $index);
         } else {
             if ($method->isAnnotatedWith("Spot\\Inject\\Intercept")) {
                 $this->bindInterceptor($method, $index);
             }
         }
     }
 }
 public function bind(Type $type)
 {
     if (!$type->isInstantiable()) {
         throw new ConfigurationException("Type {$type->name} is not instantiable");
     }
     $dependencies = [];
     $ctor = $type->getConstructor();
     foreach ($ctor ? $ctor->getParameters() : [] as $parameter) {
         $dependencies[] = $this->bindParameter($parameter);
     }
     $this->bindings->put(new InlineBinding($type, $dependencies));
 }
 public function generateDependencyInjection(Type $type, CodeWriter $writer)
 {
     $ctor = $type->getConstructor();
     $route = $type->getAnnotation("Spot\\App\\Web\\Route");
     $paths = $this->compiler->parse($route->value);
     $parameters = $ctor->getParameters();
     if ($parameters) {
         $this->generateDependencyInjectionParameter(array_shift($parameters), $paths, $writer);
         foreach ($parameters as $parameter) {
             $writer->write(', ');
             $this->generateDependencyInjectionParameter($parameter, $paths, $writer);
         }
     }
 }
Exemple #5
0
 public function generate(Type $type, CodeWriter $writer)
 {
     $writer->writeln('public $i, $k, $d;');
     $writer->write('function __construct(Spot\\Inject\\Injector $i, Spot\\Inject\\Key $k) {');
     $writer->indent();
     $writer->write('$this->i = $i;');
     $writer->write('$this->k = $k;');
     $writer->outdent();
     $writer->writeln('}');
     $writer->write("function __() {");
     $writer->indent();
     $writer->write('return $this->d ?: $this->d = $this->i->get($this->k);');
     $writer->outdent();
     $writer->write("}");
     foreach ($type->getMethods(Method::IS_PUBLIC) as $method) {
         if (!$method->isConstructor()) {
             $this->generateMethod($method, $writer);
         }
     }
 }
 public function generate(Type $type, CodeWriter $writer)
 {
     $writer->write('function __construct($s, $m, $i, $r, $d) {');
     $writer->indent();
     $writer->writeln('$this->s = $s;');
     $writer->writeln('$this->m = $m;');
     $writer->writeln('$this->i = $i;');
     $writer->writeln('$this->r = $r;');
     $writer->write('$this->d = $d;');
     $writer->outdent();
     $writer->writeln("}");
     foreach ($type->getMethods(Method::IS_PUBLIC) as $method) {
         if ($method->isConstructor()) {
             continue;
         }
         if ($this->pointCuts->matches($method)) {
             $this->generateMethod($method, $this->pointCuts->getAdvices($method), $writer);
         } else {
             $this->generateDelegateMethod($method, $writer);
         }
     }
 }
Exemple #7
0
 public function matches(Type $type)
 {
     return $type->isSubtypeOf($this->s);
 }
Exemple #8
0
 public function matches(Type $type)
 {
     return $type->isAnnotatedWith($this->a);
 }
 public function matches(Type $type)
 {
     return $type->isInstantiable();
 }