Finds all properties in class.

@param \ReflectionClass $reflection
343399
protected function findProperties(\ReflectionClass $reflection): void
    {
        if (false !== $reflection->getParentClass()) {
            $this->findProperties($reflection->getParentClass());
        }

        $this->properties = array_unique(array_merge($this->properties, array_keys($reflection->getDefaultProperties())));
    }
34450
private function extractAllowedAttributes(ReflectionClass $reflection): array
    {
        $allowed = [];
        foreach (
            $reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method
        ) {
            if (!$this->isGetMethod($method)) {
                continue;
            }

            $name = $this->getAttributeName($method);
            if ($this->isExclude($name)) {
                continue;
            }

            $allowed[] = $name;
        }

        return $allowed;
    }
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();
    }
451020
private function getParentClassNames(\ReflectionClass $reflectionClass)
    {
        $parentClassNames = [];

        while ($parent = $reflectionClass->getParentClass()) {
            $parentClassNames[] = $parent->getName();
            $reflectionClass = $parent;
        }

        return $parentClassNames;
    }
1221921
final private static function sortConstants(ReflectionClass $reflection): array
    {
        $constants = [];
        while ($reflection && __CLASS__ !== $reflection->getName()) {
            $scope = [];
            foreach ($reflection->getReflectionConstants() as $const) {
                if ($const->isPublic()) {
                    $scope[$const->getName()] = $const->getValue();
                }
            }
            $constants = $scope + $constants;
            $reflection = $reflection->getParentClass();
        }


        return $constants;
    }
1112344
private function hasFileEncryptionEnabled(\ReflectionClass $reflection)
    {
        $classMetadata = $this->getEncryptionMetadataFor($reflection->getName());
        return $classMetadata->encryptionEnabled && $classMetadata->encryptedFile;
    }
184857
protected function getPropertyTypes($class)
    {
        $class = new \ReflectionClass($class);
        $properties = $class->getDefaultProperties();
        $propertyTypes = [];

        // This prevents any default string value, so it could be enhanced
        foreach ($properties as $propName => $property) {
            if (is_string($property) && (class_exists($property) || interface_exists($property))) {
                $propertyTypes[$propName] = $property;
            }
        }
        return $propertyTypes;
    }
778314
private function getDocumentPropertiesReflection(\ReflectionClass $reflectionClass)
    {
        if (in_array($reflectionClass->getName(), $this->properties)) {
            return $this->properties[$reflectionClass->getName()];
        }

        $properties = [];

        foreach ($reflectionClass->getProperties() as $property) {
            if (!in_array($property->getName(), $properties)) {
                $properties[$property->getName()] = $property;
            }
        }

        $parentReflection = $reflectionClass->getParentClass();
        if ($parentReflection !== false) {
            $properties = array_merge(
                $properties,
                array_diff_key($this->getDocumentPropertiesReflection($parentReflection), $properties)
            );
        }

        $this->properties[$reflectionClass->getName()] = $properties;

        return $properties;
    }
793885
public function getPropertyTypes(\ReflectionProperty $property) : array
    {
        $docComment = $property->getDocComment();

        if ($docComment === false) {
            return [];
        }

        if (preg_match('/@var\s+(\S+)/', $docComment, $matches) !== 1) {
            return [];
        }

        return explode('|', $matches[1]);
    }
683360
public function process(\ReflectionClass $reflection, Definition $definition)
    {
        foreach ($reflection->getProperties() as $property)
        {
            $this->processProperty($property, $definition);
        }

        foreach ($reflection->getMethods() as $method)
        {
            $this->processMethod($method, $definition);
        }
    }
456506
protected function findReflectionProperty($property, \ReflectionClass $reflection)
    {
        if ($reflection->hasProperty($property)) {
            $refProp = $reflection->getProperty($property);
            $refProp->setAccessible(true);

            return $refProp;
        }

        if (false !== $reflection->getParentClass()) {
            return $this->findReflectionProperty($property, $reflection->getParentClass());
        }

        throw new InvalidArgumentException(sprintf('The "%s" property is not found in "%s" class.', $property, $this->getDataClass()));
    }
242504
public function loadMetadataForClass(\ReflectionClass $reflectionClass)
    {
        $className = $reflectionClass->getName();
        $classMetadata = new ClassMetadata($className);
        $classMetadata->fileResources[] = $reflectionClass->getFileName();

        $encryptionAnnotation = $this->reader->getClassAnnotation(
            $reflectionClass,
            'Jagilpe\\EncryptionBundle\\Annotation\\EncryptedEntity'
        );
        /** @var EncryptedEntity $encryptionAnnotation */
        if ($encryptionAnnotation) {
            $classMetadata->encryptionEnabled = $encryptionAnnotation->enabled;
            $classMetadata->encryptionMode = $encryptionAnnotation->mode;

            $encryptedFileAnnotation = $this->reader->getClassAnnotation(
                $reflectionClass,
                'Jagilpe\\EncryptionBundle\\Annotation\\EncryptedFile'
            );

            /** @var EncryptedFile $encryptedFileAnnotation */
            if ($encryptedFileAnnotation) {
                $classMetadata->encryptedFile = $encryptedFileAnnotation->enabled;
                $classMetadata->encryptedFileMode = $encryptedFileAnnotation->mode;
            }

            foreach ($reflectionClass->getProperties() as $reflectionProperty) {
                $propertyAnnotation = $this->reader->getPropertyAnnotation(
                    $reflectionProperty,
                    'Jagilpe\\EncryptionBundle\\Annotation\\EncryptedField'
                );

                /** @var EncryptedField $propertyAnnotation */
                if ($propertyAnnotation) {
                    $propertyMetadata = new PropertyMetadata($reflectionClass->getName(), $reflectionProperty->getName());
                    $propertyMetadata->encrypted = $propertyAnnotation->enabled;

                    $classMetadata->addPropertyMetadata($propertyMetadata);
                }
            }
        }
        else {
            $classMetadata->encryptionEnabled = false;
        }

        return $classMetadata;
    }
745904
private function accessProperty(ReflectionClass $reflection, $property)
    {
        $propertyReflection = $reflection->getProperty($property);
        $propertyReflection->setAccessible(true);

        return $propertyReflection;
    }
1254160
public function parseMethods(\ReflectionClass $ref)
    {
        foreach($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $method)
        {
            $this->parseMethod($ref, $method);
        }
    }
744079
private static function getProperties($class): array
    {
        $reflect = new \ReflectionClass($class);
        $prop = $reflect->getProperties(
            \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE
        );
        $properties = [];
        foreach ($prop as $property) {
            $properties[] = $property->name;
        }
        $parent = \get_parent_class($class);
        if ($parent) {
            $properties = \array_merge(self::getProperties($parent), $properties);
        }
        return $properties;
    }
637688
private function hasSetMethod($reflectionClass, $propertyName): bool
    {
        $studlyProperty = $this->studly($propertyName);
        $methodName = 'set' . $studlyProperty;
        $exists = $reflectionClass->hasMethod($methodName);

        return $exists;
    }
222252
private function getParentProperties(\ReflectionClass $reflectionClass)
    {
        $parent = $reflectionClass->getParentClass();
        if ($parent != null) {
            return array_merge($reflectionClass->getProperties(), $this->getParentProperties($parent));
        }

        return $reflectionClass->getProperties();
    }