Exemplo n.º 1
0
 public function testIfHasMethodAnnotationFromInterface()
 {
     // Check base model first
     $info = new ReflectionAnnotatedMethod(BaseInterfaceWithLabel::class, 'getTitle');
     $has = $info->hasAnnotation('Label');
     $this->assertTrue($has);
     // Check inherited model model
     $model = new ModelWithInheritedLabelFromInterface();
     $info = new ReflectionAnnotatedMethod($model, 'getTitle');
     $has = $info->hasAnnotation('Label');
     $this->assertTrue($has);
 }
Exemplo n.º 2
0
 /**
  * Get reflection class.
  * @param ReflectionAnnotatedClass|ReflectionAnnotatedProperty|ReflectionAnnotatedMethod $reflection Reflection
  * @return ReflectionAnnotatedClass
  * @throws Exception
  */
 public static function getReflectionClass($reflection)
 {
     if (null === $reflection) {
         throw new Exception(sprintf('No reflection class for matcher `%s`', get_class($this)));
     }
     if ($reflection instanceof ReflectionAnnotatedMethod) {
         return $reflection->getDeclaringClass();
     }
     if ($reflection instanceof ReflectionAnnotatedProperty) {
         return $reflection->getDeclaringClass();
     }
     return $reflection;
 }
Exemplo n.º 3
0
 public function testIfHasMethodAnnotationFromParentClassParent()
 {
     // Check base model first
     $model = new BaseModelWithLabel();
     $info = new ReflectionAnnotatedMethod($model, 'getTitle');
     $has = $info->hasAnnotation('Label');
     $this->assertTrue($has);
     // Check inherited model model
     $model = new ModelWithInheritedLabelDeep();
     $info = new ReflectionAnnotatedMethod($model, 'getTitle');
     $has = $info->hasAnnotation('Label');
     $this->assertTrue($has);
 }