Parses analyzers list from document mapping.

@param \ReflectionClass $reflectionClass
@return array
169618
private function getAnalyzers(\ReflectionClass $reflectionClass)
    {
        $analyzers = [];

        foreach ($this->getDocumentPropertiesReflection($reflectionClass) as $name => $property) {
            $directory = $this->guessDirName($property->getDeclaringClass());

            $type = $this->getPropertyAnnotationData($property);
            $type = $type !== null ? $type : $this->getEmbeddedAnnotationData($property);

            if ($type instanceof Embedded) {
                $analyzers = array_merge(
                    $analyzers,
                    $this->getAnalyzers(new \ReflectionClass($this->finder->getNamespace($type->class, $directory)))
                );
            }

            if ($type instanceof Property) {
                if (isset($type->options['analyzer'])) {
                    $analyzers[] = $type->options['analyzer'];
                }
                if (isset($type->options['search_analyzer'])) {
                    $analyzers[] = $type->options['search_analyzer'];
                }

                if (isset($type->options['fields'])) {
                    foreach ($type->options['fields'] as $field) {
                        if (isset($field['analyzer'])) {
                            $analyzers[] = $field['analyzer'];
                        }
                        if (isset($field['search_analyzer'])) {
                            $analyzers[] = $field['search_analyzer'];
                        }
                    }
                }
            }
        }
        return array_unique($analyzers);
    }
255323
public function generate(ReflectionClass $originalClass) : array
    {
        $ast = [new Class_($originalClass->getShortName())];

        $namespace = $originalClass->getNamespaceName();
        if ($namespace) {
            $ast = [new Namespace_(new Name(explode('\\', $namespace)), $ast)];
        }

        $implementor = new NodeTraverser();
        $implementor->addVisitor(new HydratorMethodsVisitor($originalClass));
        $implementor->addVisitor(new ClassImplementorVisitor($originalClass->getName(), [HydratorInterface::class]));

        return $implementor->traverse($ast);
    }
287750
public function parseClass(\ReflectionClass $class)
    {
        if (false === $filename = $class->getFilename()) {
            return array();
        }

        $content = $this->getFileContent($filename, $class->getStartLine());
        $namespace = str_replace('\\', '\\\\', $class->getNamespaceName());
        $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
        $this->tokens = token_get_all('<?php ' . $content);
        $this->numTokens = count($this->tokens);
        $this->pointer = 0;

        $statements = $this->parseUseStatements($class->getNamespaceName());

        return $statements;
    }
1178168
private function findReader(ReflectionClass $class): Reader
    {
        $className = $class->getName();
        foreach ($this->chainDriver->getDrivers() as $namespace => $driver) {
            if (mb_stripos($className, $namespace) === 0) {
                if ($driver instanceof AnnotationDriver) {
                    return $driver->getReader();
                }
            }
        }

        if ($this->chainDriver->getDefaultDriver() instanceof AnnotationDriver) {
            return $this->chainDriver->getDefaultDriver()->getReader();
        }

        throw new Exception('graphql-doctrine requires ' . $className . ' entity to be configured with a `' . AnnotationDriver::class . '`.');
    }
484997
protected static function parse(\ReflectionClass $oReflectionClass)
    {
        $sContent = file_get_contents($oReflectionClass->getFileName());
        $aTokens  = token_get_all($sContent);

        $sDocComment = null;
        $bIsConst    = false;
        foreach ($aTokens as $aToken) {
            if (!is_array($aToken) || count($aToken) <= 1) {
                continue;
            }

            list($iTokenType, $sTokenValue) = $aToken;

            switch ($iTokenType) {
                // Ignored tokens
                case T_WHITESPACE:
                case T_COMMENT:
                    break;

                case T_DOC_COMMENT:
                    $sDocComment = $sTokenValue;
                    break;

                case T_CONST:
                    $bIsConst = true;
                    break;

                case T_STRING:
                    if ($bIsConst) {
                        static::$aDescriptions[$sTokenValue] = self::extractDescription($sDocComment);
                        static::$aArguments[$sTokenValue]    = self::extractArgument($sDocComment);
                    }
                    $sDocComment = null;
                    $bIsConst    = false;
                    break;

                // All other tokens reset the parser
                default:
                    $sDocComment = null;
                    $bIsConst    = false;
                    break;
            }
        }
    }
349468
public function getConditions(ReflectionClass $class, string $methodName): array
    {
        $annotations   = [];
        $parentMethods = [];
        $docComment    = $class->getMethod($methodName)->getDocComment();

        if ($docComment === false) {
            return $annotations;
        }

        if (\preg_match('/\@inheritdoc/i', $docComment)) {
            $this->getParentClassesMethods($class, $methodName, $parentMethods);
            $this->getInterfacesMethods($class, $methodName, $parentMethods);
        }

        foreach ($parentMethods as $parentMethod) {
            $annotations[] = $this->annotationReader->getMethodAnnotations($parentMethod);
        }

        if (\count($annotations)) {
            $annotations = \array_merge(...$annotations);
        }

        return $this->filterContractAnnotation($annotations);
    }
755978
public function loadMetadataForClass(\ReflectionClass $class)
    {
        $classMetadata = new MergeableClassMetadata($class->getName());

        foreach ($class->getProperties() as $reflectionProperty) {
            $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());

            /** @var $annotation \Zicht\Bundle\FileManagerBundle\Annotation\File */
            $annotation = $this->reader->getPropertyAnnotation(
                $reflectionProperty,
                'Zicht\Bundle\FileManagerBundle\Annotation\File'
            );
            if (null !== $annotation) {
                // a "@DefaultValue" annotation was found
                $propertyMetadata->fileManager = $annotation->settings;
            }

            $classMetadata->addPropertyMetadata($propertyMetadata);
        }

        return $classMetadata;
    }
326921
protected function generateImplements(\ReflectionClass $reflectionClass)
    {

        // load the class interfaces
        $interfaces = $reflectionClass->getInterfaces();

        // initialize the array for the
        $generateInterfaces = array();

        // iterate over the specified interfaces
        foreach ($interfaces as $interfaceName => $interface) {
            // clean them up to avoid doubles
            foreach ($generateInterfaces as $obj) {
                if ($obj->isSubclassOf($interface)) {
                    continue 2;
                }
            }

            // traversable interface can not be implemented directly, so ignore it
            if ($interface->getName() === 'Traversable') {
                continue;
            }

            // append the interface
            $generateInterfaces[sprintf('\\%s', $interfaceName)] = $interface;
        }

        // implode the interfaces and return them as string
        return implode(', ', array_keys($generateInterfaces));
    }
547241
protected function getPropertiesMeta(ReflectionClass $reflection): array
    {
        $meta = [];
        $defaults = $reflection->getDefaultProperties();
        $properties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);

        foreach ($properties as $item) {
            $name = $item->getName();
            $meta[$name] = [
                'name' => $name,
                'title' => uncase($name)
            ];

            if (array_key_exists($name, $defaults)) {
                $meta[$name]['default'] = $defaults[$name];
            }
        }

        return $meta;
    }
1212341
public function classify(ReflectionClass $class)
    {
        $mergedClassifiers = array_merge(
            self::DEFAULT_CLASSIFIER,
            config('stats.custom_component_classifier', [])
        );

        foreach ($mergedClassifiers as $classifier) {
            $c = new $classifier();

            if (! $this->implementsContract($classifier)) {
                throw new Exception("Classifier {$classifier} does not implement ".ClassifierContract::class.'.');
            }

            try {
                $satisfied = $c->satisfies($class);
            } catch (Exception $e) {
                $satisfied = false;
            }

            if ($satisfied) {
                return $c->getName();
            }
        }

        return 'Other';
    }
558260
private function extractProperties(\ReflectionClass $objectClass): array
    {
        return propertiesOf($objectClass, \ReflectionProperty::IS_PUBLIC)
                ->filter(function(\ReflectionProperty $property)
                        {
                            return !$property->isStatic()
                                && !annotationsOf($property)->contain('XmlIgnore');
                        }
                )->map(function(\ReflectionProperty $property)
                        {
                            return $this->createSerializerDelegate(
                                    annotationsOf($property),
                                    $property->getName()
                            );
                        }
                )->data();
    }
107603
protected function getPropertiesMeta(ReflectionClass $reflection): array
    {
        $meta = [];
        $properties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC);

        foreach ($properties as $item) {
            $doc = $item->getDocComment();
            $notations = $this->parser->parse($doc);

            if (count($notations) > 0) {
                $meta[$item->getName()] = $notations;
            }
        }

        return $meta;
    }
957748
public function getConditions(ReflectionClass $class, string $methodName): array
    {
        $annotations = [];
        $parentMethods = [];

        $this->getParentClassesMethods($class, $methodName, $parentMethods);
        $this->getInterfacesMethods($class, $methodName, $parentMethods);

        foreach ($parentMethods as $parentMethod) {
            $annotations[] = $this->annotationReader->getMethodAnnotations($parentMethod);
        }

        if (\count($annotations) > 0) {
            $annotations = \array_merge(...$annotations);
        }

        return $this->filterContractAnnotation($annotations);
    }
914688
public function getSorts(\ReflectionClass $reflectionClass)
    {
        if ($this->isProduction()) {
            $this->grid->getSort()->getFields();
        }

        $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PRIVATE | \ReflectionProperty::IS_PROTECTED);
        /** @var \ReflectionProperty $property */
        foreach ($properties as $property) {
            $propertyAnnotations = $this->extractorFactory->extract($property, Extractor::PROPERTY_ANNOTATION);
            foreach ($propertyAnnotations as $annotation) {
                if ($annotation instanceof Sort) {
                    $fields[] = $property->getName();
                }
            }
        }

        return !empty($fields) ? $fields : $this->grid->getSort()->getFields();
    }
888280
private function getFromAnnotation(ReflectionClass $class): array
    {
        $sortings = Utils::getRecursiveClassAnnotations($this->getAnnotationReader(), $class, Sorting::class);

        $result = [];
        foreach ($sortings as $classWithAnnotation => $sorting) {
            foreach ($sorting->classes as $className) {
                $this->throwIfInvalidAnnotation($classWithAnnotation, 'Sorting', SortingInterface::class, $className);

                $name = lcfirst(preg_replace('~Type$~', '', Utils::getTypeName($className)));
                $result[$name] = new $className();
            }
        }

        return $result;
    }
813565
public static function getProperties(Reader $reader, ReflectionClass $class)
    {
        $props  = $class->getProperties();
        $result = [];

        foreach ($props as $property) {
            // skip statics
            if ($property->isStatic()) {
                continue;
            }

            // check whether we have an exclude annotation
            $exclude = $reader->getPropertyAnnotation($property, Annotation\Exclude::class);
            if ($exclude !== null) {
                continue;
            }

            // get the property name
            $key  = $reader->getPropertyAnnotation($property, Annotation\Key::class);
            $name = null;

            if ($key !== null) {
                $name = $key->getKey();
            }

            if (empty($name)) {
                $name = $property->getName();
            }

            $result[$name] = $property;
        }

        return $result;
    }
504965
private function getClassProperties(ReflectionClass $reflectionClass)
    {
        $properties = $reflectionClass->getProperties();

        return array_filter(
            array_filter(array_map(
                [$this, 'getAccessibleProperty'],
                array_combine(
                    array_map([$this, 'getLogicalName'], $properties),
                    $properties
                )
            )),
            [$this, 'isInstanceProperty']
        );
    }