/**
  * @test
  */
 public function parseAnnotation()
 {
     $doc = '/** @var string */';
     $annotationData = $this->parser->parse($doc);
     $this->assertThat($annotationData[0]->name, $this->equalTo('var'));
     $doc = '/** @ORM\\Column(name="createdAt") */';
     $annotationData = $this->parser->parse($doc);
     $this->assertThat($annotationData[0]->name, $this->equalTo('ORM\\Column'));
     $this->assertThat($annotationData[0]->values, $this->equalTo(['name' => 'createdAt']));
 }
Beispiel #2
0
 /**
  * @param ReflectionClass|String $clazz
  */
 public static function getClassAnnotations($clazz)
 {
     $className = $clazz instanceof ReflectionClass ? $clazz->getName() : $clazz;
     if (!isset(self::$classCache[$className])) {
         $clazz = $clazz instanceof ReflectionClass ? $clazz : new ReflectionClass($clazz);
         self::$classCache[$className] = AnnotationsParser::parse($clazz->getDocComment());
     }
     return self::$classCache[$className];
 }
 public function testAnnotationsParser()
 {
     $parser = new AnnotationsParser();
     $block = "\n\t\t\t\t/**\n\t\t\t\t * @TestAnnotation(ratio = 2.5)\n\t\t\t\t * @AnotherAnnotation('Hello')\n\t\t\t\t **/";
     $annotations = $parser->parse($block);
     $first = $annotations['TestAnnotation'];
     $second = $annotations['AnotherAnnotation'];
     $this->assertIsA($first, 'TestAnnotation');
     $this->assertEqual($first->ratio, 2.5);
     $this->assertIsA($second, 'AnotherAnnotation');
     $this->assertEqual($second->value, 'Hello');
 }