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;
    }