Exemplo n.º 1
0
 public function check(Type $type)
 {
     foreach ($type->getMethods(Method::IS_PUBLIC) as $method) {
         if ($this->pointCuts->matches($method)) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 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);
             }
         }
     }
 }
Exemplo n.º 3
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);
         }
     }
 }
Exemplo n.º 4
0
 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);
         }
     }
 }