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); }
/** * 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; }
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); }