@param \ReflectionClass $reflection
@param $propertyName

@return ReflectionProperty
434234
protected function getProperty(\ReflectionClass $reflection, $propertyName): ReflectionProperty
    {
        $property = $reflection->getProperty($propertyName);
        $property->setAccessible(true);
        return $property;
    }
519295
public static function from(\ReflectionProperty $reflection) : PropertyAccessibility
    {
        if ($reflection->isPublic()) {
            $accessibility = self::ACCESS_PUBLIC;
        } elseif ($reflection->isProtected()) {
            $accessibility = self::ACCESS_PROTECTED;
        } else {
            $accessibility = self::ACCESS_PRIVATE;
        }

        return new self($accessibility, $reflection->getDeclaringClass()->getName());
    }
412678
protected function buildProperty(ReflectionProperty $reflectionProperty) : Node\Stmt\Property
    {
        $propertyBuilder = new Property($reflectionProperty->getName());

        if ($reflectionProperty->isPublic()) {
            $propertyBuilder->makePublic();
        }

        if ($reflectionProperty->isProtected()) {
            $propertyBuilder->makeProtected();
        }

        if ($reflectionProperty->isPrivate()) {
            $propertyBuilder->makePrivate();
        }

        if ($reflectionProperty->isStatic()) {
            $propertyBuilder->makeStatic();
        }

        if ($reflectionProperty->isDefault()) {
            $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();

            $propertyBuilder->setDefault($allDefaultProperties[$reflectionProperty->getName()]);
        }

        return $propertyBuilder->getNode();
    }
307826
protected function getReflectionProperty($class, $property)
    {
        if (!isset($this->propertyReflectors[$class])) {
            $this->propertyReflectors[$class] = [];
        }
        if (!isset($this->propertyReflectors[$class][$property])) {
            $this->propertyReflectors[$class][$property] = new \ReflectionProperty($class, $property);
        }

        return $this->propertyReflectors[$class][$property];
    }
1330993
public function getPropertyAnnotations($className, $propertyName, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_PROPERTIES][$propertyName][self::DATA_PROPERTY_ANNOTATIONS])) {
            return [];
        }

        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_PROPERTIES][$propertyName][self::DATA_PROPERTY_ANNOTATIONS];
        }

        if (isset($this->classReflectionData[$className][self::DATA_CLASS_PROPERTIES][$propertyName][self::DATA_PROPERTY_ANNOTATIONS][$annotationClassName])) {
            return $this->classReflectionData[$className][self::DATA_CLASS_PROPERTIES][$propertyName][self::DATA_PROPERTY_ANNOTATIONS][$annotationClassName];
        }

        return [];
    }
231297
private function isPropertyAccessible($propertyName)
    {
        $result = false;
        $className = get_class($this);
        $reflectionService = ReflectionService::get();

        if ($reflectionService->isClassPropertyAccessible($className, $propertyName)) {
            $property = $reflectionService->getClassAccessibleProperty($className, $propertyName);
            $result = false === $property->isTaggedWith('disableMagicMethods');
        }

        return $result;
    }
640761
public static function getMaskAnnotation($classMetadata, $propertyName)
    {
        if ($propertyName instanceof ReflectionProperty) {
            $propertyName = $propertyName->getName();
        }

        $path_hub_mask = self::PATH_HUB_MASK;
        $hubName = $classMetadata->$path_hub_mask[$propertyName];

        $path = self::PATH_MASK_BY_HUB;

        return $classMetadata->$path[$hubName][$propertyName][self::ANNOTATION];
    }
44613
protected static function createProperty(\ReflectionProperty $reflectionProperty)
    {
        $property = new Property();
        $property->setName($reflectionProperty->getName());
        
        $annotationReader = new AnnotationReader();
        $annotations = $annotationReader->getPropertyAnnotations($reflectionProperty);
        foreach ($annotations as $annotation) {
            $annotationClassName = get_class($annotation);
            if ($annotationClassName == 'Doctrine\ORM\Mapping\Column' || $annotationClassName == 'Doctrine\ORM\Mapping\Id') {
                $property->setAnnotation($annotation);
                $property->setType(Property::PROPERTY_TYPE_COLUMN);
            } elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToOne' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToOne') {
                $property->setAnnotation($annotation);
                $property->setType(Property::PROPERTY_TYPE_REF_ONE);
                $property->setTargetEntity($annotation->targetEntity);
            } elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToMany' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToMany') {
                $property->setAnnotation($annotation);
                $property->setType(Property::PROPERTY_TYPE_REF_MANY);
                $property->setTargetEntity($annotation->targetEntity);
            }
        }
        
        if ($property->getType() == -1) {
            throw new \Exception(
                'Entity "' . $reflectionProperty->getDeclaringClass()->getName()
                . '": defining annotation is missing at property "' . $property->getName() . '"!'
            );
        }
        
        return $property;
    }
129978
private function set($object, $propertyName, $propertyValue)
    {
        $reflectionUser = new \ReflectionClass($object);

        $reflectionProperty = $reflectionUser->getProperty($propertyName);
        $reflectionProperty->setAccessible(true);
        $reflectionProperty->setValue($object, $propertyValue);

        return $object;
    }
861341
public function getDefaultPropertyValue($className, $propertyName)
    {
        $reflection = new \ReflectionClass($className);
        $values = $reflection->getDefaultProperties();
        return $values[$propertyName] ?? null;
    }
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()));
    }
1221475
protected function mapToClass($propertyName, $className, \Closure $callback)
    {
        $temporary = new GenericDataMapper($this->resolver);
        $callback($temporary);
        if (!is_null($className)) {
            $temporary->toClassName                     = $className;
        }
        $this->properties[]                       = $propertyName;
        $this->propertiesToClasses[$propertyName] = $temporary;

        return $this;
    }
481403
private function getPropertyValue(ReflectionClass $reflection, $property, $object)
    {
        $propertyReflection = $this->accessProperty($reflection, $property);
        $value = $propertyReflection->getValue($object);
        $propertyReflection->setAccessible(false);

        return $value;
    }
980053
private function convertPropertyAnnotationsToProperty(
        array $propertyAnnotations,
        ReflectionProperty $reflectionProperty,
        Mapping\ClassMetadata $metadata
    ) : ?Mapping\Property {
        switch (true) {
            case isset($propertyAnnotations[Annotation\Column::class]):
                return $this->convertReflectionPropertyToFieldMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\OneToOne::class]):
                return $this->convertReflectionPropertyToOneToOneAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\ManyToOne::class]):
                return $this->convertReflectionPropertyToManyToOneAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\OneToMany::class]):
                return $this->convertReflectionPropertyToOneToManyAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\ManyToMany::class]):
                return $this->convertReflectionPropertyToManyToManyAssociationMetadata(
                    $reflectionProperty,
                    $propertyAnnotations,
                    $metadata
                );
            case isset($propertyAnnotations[Annotation\Embedded::class]):
                return null;
            default:
                return new Mapping\TransientMetadata($reflectionProperty->getName());
        }
    }
443777
private function getAccessibleProperty(ReflectionProperty $property)
    {
        return $this->reflectionService->getAccessibleProperty(
            $property->getDeclaringClass()->getName(),
            $property->getName()
        );
    }
48909
protected function getProperty($reflectionObject, $entity, $name)
    {
        $property = $reflectionObject->getProperty($name);
        $property->setAccessible(true);
        return $property->getValue($entity);
    }
228782
private function convertReflectionPropertyToOneToOneAssociationMetadata(
        ReflectionProperty $reflectionProperty,
        array $propertyAnnotations,
        Mapping\ClassMetadata $classMetadata
    ) {
        $className     = $classMetadata->getClassName();
        $fieldName     = $reflectionProperty->getName();
        $oneToOneAnnot = $propertyAnnotations[Annotation\OneToOne::class];

        if ($oneToOneAnnot->targetEntity === null) {
            throw Mapping\MappingException::missingTargetEntity($fieldName);
        }

        $assocMetadata = new Mapping\OneToOneAssociationMetadata($fieldName);
        $targetEntity  = $oneToOneAnnot->targetEntity;

        $assocMetadata->setSourceEntity($className);
        $assocMetadata->setTargetEntity($targetEntity);
        $assocMetadata->setCascade($this->getCascade($className, $fieldName, $oneToOneAnnot->cascade));
        $assocMetadata->setOrphanRemoval($oneToOneAnnot->orphanRemoval);
        $assocMetadata->setFetchMode($this->getFetchMode($className, $oneToOneAnnot->fetch));

        if (! empty($oneToOneAnnot->mappedBy)) {
            $assocMetadata->setMappedBy($oneToOneAnnot->mappedBy);
        }

        if (! empty($oneToOneAnnot->inversedBy)) {
            $assocMetadata->setInversedBy($oneToOneAnnot->inversedBy);
        }

        // Check for Id
        if (isset($propertyAnnotations[Annotation\Id::class])) {
            $assocMetadata->setPrimaryKey(true);
        }

        // Check for Cache
        if (isset($propertyAnnotations[Annotation\Cache::class])) {
            $cacheAnnot    = $propertyAnnotations[Annotation\Cache::class];
            $cacheMetadata = $this->convertCacheAnnotationToCacheMetadata($cacheAnnot, $classMetadata, $fieldName);

            $assocMetadata->setCache($cacheMetadata);
        }

        // Check for JoinColumn/JoinColumns annotations
        switch (true) {
            case isset($propertyAnnotations[Annotation\JoinColumn::class]):
                $joinColumnAnnot = $propertyAnnotations[Annotation\JoinColumn::class];
                $joinColumn      = $this->convertJoinColumnAnnotationToJoinColumnMetadata(
                    $reflectionProperty,
                    $joinColumnAnnot,
                    $classMetadata
                );

                $assocMetadata->addJoinColumn($joinColumn);

                break;

            case isset($propertyAnnotations[Annotation\JoinColumns::class]):
                $joinColumnsAnnot = $propertyAnnotations[Annotation\JoinColumns::class];

                foreach ($joinColumnsAnnot->value as $joinColumnAnnot) {
                    $joinColumn = $this->convertJoinColumnAnnotationToJoinColumnMetadata(
                        $reflectionProperty,
                        $joinColumnAnnot,
                        $classMetadata
                    );

                    $assocMetadata->addJoinColumn($joinColumn);
                }

                break;
        }

        return $assocMetadata;
    }