original_string: protected function getControllerAnnotation(\ReflectionFunctionAbstract $controller, string $annotationClass)
      {
          if ($controller instanceof \ReflectionMethod) {
              $annotations = $this->annotationReader->getMethodAnnotations($controller);
              foreach ($annotations as $annotation) {
                  if ($annotation instanceof $annotationClass) {
                      return $annotation;
                  }
              }
  
              $class = $controller->getDeclaringClass();
              $classes = $this->reflectionTools->getClassHierarchy($class);
  
              foreach ($classes as $class) {
                  $annotations = $this->annotationReader->getClassAnnotations($class);
                  foreach ($annotations as $annotation) {
                      if ($annotation instanceof $annotationClass) {
                          return $annotation;
                      }
                  }
              }
          }
  
          return null;
      }
code: protected function getControllerAnnotation(\ReflectionFunctionAbstract $controller, string $annotationClass)
      {
          if ($controller instanceof \ReflectionMethod) {
              $annotations = $this->annotationReader->getMethodAnnotations($controller);
              foreach ($annotations as $annotation) {
                  if ($annotation instanceof $annotationClass) {
                      return $annotation;
                  }
              }
  
              $class = $controller->getDeclaringClass();
              $classes = $this->reflectionTools->getClassHierarchy($class);
  
              foreach ($classes as $class) {
                  $annotations = $this->annotationReader->getClassAnnotations($class);
                  foreach ($annotations as $annotation) {
                      if ($annotation instanceof $annotationClass) {
                          return $annotation;
                      }
                  }
              }
          }
  
          return null;
      }
code_tokens: protected function getControllerAnnotation ( \ ReflectionFunctionAbstract $ controller , string $ annotationClass ) { if ( $ controller instanceof \ ReflectionMethod ) { $ annotations = $ this -> annotationReader -> getMethodAnnotations ( $ controller ) ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof $ annotationClass ) { return $ annotation ; } } $ class = $ controller -> getDeclaringClass ( ) ; $ classes = $ this -> reflectionTools -> getClassHierarchy ( $ class ) ; foreach ( $ classes as $ class ) { $ annotations = $ this -> annotationReader -> getClassAnnotations ( $ class ) ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof $ annotationClass ) { return $ annotation ; } } } } return null ; }
docstring: Finds an annotation on the controller class or method.
  
  If the annotation is found on both the controller class and method, the method annotation is returned.
  If the annotation is found on several classes in the hierarchy of controller classes,
  the annotation of the child class is returned.
  
  This method does not support controller functions outside a class.
  
  @param \ReflectionFunctionAbstract $controller
  @param string                      $annotationClass
  
  @return object|null The annotation, or null if not found.
docstring_tokens: Finds an annotation on the controller class or method .