public function parse(\ReflectionClass $class)
    {
        $className = $class->getName();

        if ($class->isTrait()) {
            return false;
        }

        if (!isset($this->documents[$className])) {
            /** @var Document $document */
            $document = $this->reader->getClassAnnotation($class, self::DOCUMENT_ANNOTATION);

            if ($document === null) {
                throw new MissingDocumentAnnotationException(
                    sprintf(
                        '"%s" class cannot be parsed as document because @Document annotation is missing.',
                        $class->getName()
                    )
                );
            }

            $fields = [];
            $aliases = $this->getAliases($class, $fields);

            $this->documents[$className] = [
                'type' => $document->type ?: Caser::snake($class->getShortName()),
                'properties' => $this->getProperties($class),
                'fields' => array_filter(
                    array_merge(
                        $document->dump(),
                        $fields
                    )
                ),
                'aliases' => $aliases,
                'analyzers' => $this->getAnalyzers($class),
                'objects' => $this->getObjects(),
                'namespace' => $class->getName(),
                'class' => $class->getShortName(),
            ];
        }
        return $this->documents[$className];
    }
public function parse(\ReflectionClass $class)
    {
        $className = $class->getName();

        if ($class->isTrait()) {
            return false;
        }

        if (!isset($this->documents[$className])) {
            /** @var Document $document */
            $document = $this->reader->getClassAnnotation($class, self::DOCUMENT_ANNOTATION);

            if ($document === null) {
                throw new MissingDocumentAnnotationException(
                    sprintf(
                        '"%s" class cannot be parsed as document because @Document annotation is missing.',
                        $class->getName()
                    )
                );
            }

            $fields = [];
            $aliases = $this->getAliases($class, $fields);

            $this->documents[$className] = [
                'type' => $document->type ?: Caser::snake($class->getShortName()),
                'properties' => $this->getProperties($class),
                'fields' => array_filter(
                    array_merge(
                        $document->dump(),
                        $fields
                    )
                ),
                'aliases' => $aliases,
                'analyzers' => $this->getAnalyzers($class),
                'objects' => $this->getObjects(),
                'namespace' => $class->getName(),
                'class' => $class->getShortName(),
            ];
        }
        return $this->documents[$className];
    }
public function parse ( \ ReflectionClass $ class ) { $ className = $ class -> getName ( ) ; if ( $ class -> isTrait ( ) ) { return false ; } if ( ! isset ( $ this -> documents [ $ className ] ) ) { /** @var Document $document */ $ document = $ this -> reader -> getClassAnnotation ( $ class , self :: DOCUMENT_ANNOTATION ) ; if ( $ document === null ) { throw new MissingDocumentAnnotationException ( sprintf ( '"%s" class cannot be parsed as document because @Document annotation is missing.' , $ class -> getName ( ) ) ) ; } $ fields = [ ] ; $ aliases = $ this -> getAliases ( $ class , $ fields ) ; $ this -> documents [ $ className ] = [ 'type' => $ document -> type ? : Caser :: snake ( $ class -> getShortName ( ) ) , 'properties' => $ this -> getProperties ( $ class ) , 'fields' => array_filter ( array_merge ( $ document -> dump ( ) , $ fields ) ) , 'aliases' => $ aliases , 'analyzers' => $ this -> getAnalyzers ( $ class ) , 'objects' => $ this -> getObjects ( ) , 'namespace' => $ class -> getName ( ) , 'class' => $ class -> getShortName ( ) , ] ; } return $ this -> documents [ $ className ] ; }
Parses documents by used annotations and returns mapping for elasticsearch with some extra metadata.

@param \ReflectionClass $class

@return array|null
@throws MissingDocumentAnnotationException
Parses documents by used annotations and returns mapping for elasticsearch with some extra metadata .