Ejemplo n.º 1
0
 /**
  * Check target constraints
  * @param ReflectionAnnotatedClass|ReflectionAnnotatedMethod|ReflectionAnnotatedProperty|bool $target Target entity
  * @param AnnotationsCollection $annotations
  * @return void
  * @throws ConflictException
  */
 public static function check($target, AnnotationsCollection $annotations)
 {
     if (!self::$_conflicts) {
         return;
     }
     foreach ($annotations->getAllAnnotations() as $annotation) {
         $name = AnnotationName::createName($annotation);
         if (!isset(self::$_conflicts[$name])) {
             continue;
         }
         $second = self::$_conflicts[$name];
         if ($annotations->hasAnnotation($second)) {
             throw new ConflictException(sprintf('Annotation `%s` cannot be used together with `%s` in `%s`', $name, $second, ReflectionName::createName($target)));
         }
     }
 }
Ejemplo n.º 2
0
 public function testIfWillProperlyNameAnnotation()
 {
     $annotation = new LabelAnnotation();
     $this->assertSame('Label', AnnotationName::createName($annotation));
 }