Example #1
0
 public function prepare()
 {
     $reader = new AnnotationReader();
     $commentParser = new AnnotationConverterAdapter($this->intf);
     $annotations = $commentParser->getClassAnnotations();
     $this->config = $this->extractDaoClassConfig($annotations);
     $this->seqHint = $this->extractAnnotation($annotations, SequenceHint::class);
     $this->methods = array_reduce($this->intf->getMethods(), function (array &$tmp, \ReflectionMethod $m) use($reader, $commentParser) {
         $attrs = $commentParser->getMethodAnnotations($m);
         $returnTypes = $this->parseReturning($this->extractAnnotation($attrs, AbstractCommandAnnotation::class));
         return $tmp + [$m->name => ['name' => $m->name, 'type' => $this->extractAnnotation($attrs, DaoAnnotation::class), 'params' => $m->getParameters(), 'paramDomain' => $this->paramToDomain($m->getParameters(), $attrs, $reader), 'returnDomain' => $this->returningToDomain($returnTypes, $attrs, $reader), 'returnTypes' => $returnTypes]];
     }, []);
 }
 /**
  * @test
  */
 public function test_parse_class_annotation()
 {
     TodoDao:
     $intf = new \ReflectionClass(TodoDao::class);
     $commentParser = new AnnotationConverterAdapter($intf);
     $annotations = $commentParser->getClassAnnotations();
     $this->assertCount(1, $annotations);
     $this->assertInstanceOf(Dao::class, $annotations[0]);
     $this->assertEquals('', $annotations[0]->route);
     TodoDao2:
     $intf = new \ReflectionClass(TodoDao2::class);
     $commentParser = new AnnotationConverterAdapter($intf);
     $annotations = $commentParser->getClassAnnotations();
     $this->assertCount(1, $annotations);
     $this->assertInstanceOf(Dao::class, $annotations[0]);
     $this->assertEquals('/', $annotations[0]->route);
 }