public static function fromClass(
        string $class,
        bool $withParents = false
    ): array
    {
        try {

            $class = new \ReflectionClass($class);
        }
        catch (\ReflectionException $e) {

            throw new Exception(
                "Class '{$class}' not found.",
                Exception::CLASS_NOT_FOUND
            );
        }

        $docComment = $class->getDocComment();

        if ($withParents) {

            while (1) {

                if ($class = $class->getParentClass()) {

                    if ($parentDoc = $class->getDocComment()) {

                        $docComment = $docComment === false ?
                            $parentDoc :
                            "{$parentDoc}{$docComment}";
                    }
                }
                else {

                    break;
                }
            }
        }

        unset($class);

        if ($docComment === false) {

            return [];
        }

        return Parser::parseDocComment($docComment);
    }
public static function fromClass(
        string $class,
        bool $withParents = false
    ): array
    {
        try {

            $class = new \ReflectionClass($class);
        }
        catch (\ReflectionException $e) {

            throw new Exception(
                "Class '{$class}' not found.",
                Exception::CLASS_NOT_FOUND
            );
        }

        $docComment = $class->getDocComment();

        if ($withParents) {

            while (1) {

                if ($class = $class->getParentClass()) {

                    if ($parentDoc = $class->getDocComment()) {

                        $docComment = $docComment === false ?
                            $parentDoc :
                            "{$parentDoc}{$docComment}";
                    }
                }
                else {

                    break;
                }
            }
        }

        unset($class);

        if ($docComment === false) {

            return [];
        }

        return Parser::parseDocComment($docComment);
    }
public static function fromClass ( string $ class , bool $ withParents = false ) : array { try { $ class = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Class '{$class}' not found." , Exception :: CLASS_NOT_FOUND ) ; } $ docComment = $ class -> getDocComment ( ) ; if ( $ withParents ) { while ( 1 ) { if ( $ class = $ class -> getParentClass ( ) ) { if ( $ parentDoc = $ class -> getDocComment ( ) ) { $ docComment = $ docComment === false ? $ parentDoc : "{$parentDoc}{$docComment}" ; } } else { break ; } } } unset ( $ class ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; }
Extract the annotations from a class.

@param string $class
@param bool $withParents

@throws \L\Annotation\Exception

@return array
Extract the annotations from a class .