public static function getRecursiveClassAnnotations(Reader $reader, ReflectionClass $class, string $annotationName): array
    {
        $result = [];

        $annotation = $reader->getClassAnnotation($class, $annotationName);
        if ($annotation) {
            $result[$class->getName()] = $annotation;
        }

        foreach ($class->getTraits() as $trait) {
            $result = array_merge($result, self::getRecursiveClassAnnotations($reader, $trait, $annotationName));
        }

        $parent = $class->getParentClass();
        if ($parent) {
            $result = array_merge($result, self::getRecursiveClassAnnotations($reader, $parent, $annotationName));
        }

        return $result;
    }
public static function getRecursiveClassAnnotations(Reader $reader, ReflectionClass $class, string $annotationName): array
    {
        $result = [];

        $annotation = $reader->getClassAnnotation($class, $annotationName);
        if ($annotation) {
            $result[$class->getName()] = $annotation;
        }

        foreach ($class->getTraits() as $trait) {
            $result = array_merge($result, self::getRecursiveClassAnnotations($reader, $trait, $annotationName));
        }

        $parent = $class->getParentClass();
        if ($parent) {
            $result = array_merge($result, self::getRecursiveClassAnnotations($reader, $parent, $annotationName));
        }

        return $result;
    }
public static function getRecursiveClassAnnotations ( Reader $ reader , ReflectionClass $ class , string $ annotationName ) : array { $ result = [ ] ; $ annotation = $ reader -> getClassAnnotation ( $ class , $ annotationName ) ; if ( $ annotation ) { $ result [ $ class -> getName ( ) ] = $ annotation ; } foreach ( $ class -> getTraits ( ) as $ trait ) { $ result = array_merge ( $ result , self :: getRecursiveClassAnnotations ( $ reader , $ trait , $ annotationName ) ) ; } $ parent = $ class -> getParentClass ( ) ; if ( $ parent ) { $ result = array_merge ( $ result , self :: getRecursiveClassAnnotations ( $ reader , $ parent , $ annotationName ) ) ; } return $ result ; }
Return an array of all annotations found in the class hierarchy, including its traits, indexed by the class name

@param Reader $reader
@param ReflectionClass $class
@param string $annotationName

@return array annotations indexed by the class name where they were found
Return an array of all annotations found in the class hierarchy including its traits indexed by the class name