@param string            $className
@param string            $name
@param string|array      $column
@param ClassMetadataInfo $metadata

@return array

@throws ToolsException
160942
private function convertColumn($className, $name, $column, ClassMetadataInfo $metadata)
    {
        if (is_string($column)) {
            $string = $column;
            $column = array();
            $column['type'] = $string;
        }

        if ( ! isset($column['name'])) {
            $column['name'] = $name;
        }

        // check if a column alias was used (column_name as field_name)
        if (preg_match("/(\w+)\sas\s(\w+)/i", $column['name'], $matches)) {
            $name = $matches[1];
            $column['name'] = $name;
            $column['alias'] = $matches[2];
        }

        if (preg_match("/([a-zA-Z]+)\(([0-9]+)\)/", $column['type'], $matches)) {
            $column['type'] = $matches[1];
            $column['length'] = $matches[2];
        }

        $column['type'] = strtolower($column['type']);
        // check if legacy column type (1.x) needs to be mapped to a 2.0 one
        if (isset($this->legacyTypeMap[$column['type']])) {
            $column['type'] = $this->legacyTypeMap[$column['type']];
        }

        if ( ! Type::hasType($column['type'])) {
            throw ToolsException::couldNotMapDoctrine1Type($column['type']);
        }

        $fieldMapping = array();

        if (isset($column['primary'])) {
            $fieldMapping['id'] = true;
        }

        $fieldMapping['fieldName'] = isset($column['alias']) ? $column['alias'] : $name;
        $fieldMapping['columnName'] = $column['name'];
        $fieldMapping['type'] = $column['type'];

        if (isset($column['length'])) {
            $fieldMapping['length'] = $column['length'];
        }

        $allowed = array('precision', 'scale', 'unique', 'options', 'notnull', 'version');

        foreach ($column as $key => $value) {
            if (in_array($key, $allowed)) {
                $fieldMapping[$key] = $value;
            }
        }

        $metadata->mapField($fieldMapping);

        if (isset($column['autoincrement'])) {
            $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
        } elseif (isset($column['sequence'])) {
            $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);

            $definition = array(
                'sequenceName' => is_array($column['sequence']) ? $column['sequence']['name']:$column['sequence']
            );

            if (isset($column['sequence']['size'])) {
                $definition['allocationSize'] = $column['sequence']['size'];
            }

            if (isset($column['sequence']['value'])) {
                $definition['initialValue'] = $column['sequence']['value'];
            }

            $metadata->setSequenceGeneratorDefinition($definition);
        }

        return $fieldMapping;
    }
873166
public static function createColumnDefinition($datatype, $name, $tableName = null, $schemaName = null)
    {
        if (!array_key_exists($datatype, self::$typesMap)) {
            throw new Exception\UnsupportedTypeException(__METHOD__ . " Type '$datatype' is not supported.");
        }
        $class = __NAMESPACE__ . '\\Column\\' . self::$typesMap[$datatype];

        return new $class($name, $tableName, $schemaName);
    }
361765
public function getColumn(string $name)
    {
        if (!isset($this->fields[$name])) {
            Throw new ColumnException(sprintf('A field named "%s" does not exist in this table', $name));
        }

        return $this->fields[$name];
    }
127859
protected function doLoadMetadata(
        string $className,
        ?ClassMetadata $parent,
        ClassMetadataBuildingContext $metadataBuildingContext
    ) : ClassMetadata {
        $classMetadata = new ClassMetadata($className, $metadataBuildingContext);

        if ($parent) {
            $classMetadata->setParent($parent);

            foreach ($parent->getDeclaredPropertiesIterator() as $fieldName => $property) {
                $classMetadata->addInheritedProperty($property);
            }

            $classMetadata->setInheritanceType($parent->inheritanceType);
            $classMetadata->setIdentifier($parent->identifier);

            if ($parent->discriminatorColumn) {
                $classMetadata->setDiscriminatorColumn($parent->discriminatorColumn);
                $classMetadata->setDiscriminatorMap($parent->discriminatorMap);
            }

            $classMetadata->setLifecycleCallbacks($parent->lifecycleCallbacks);
            $classMetadata->setChangeTrackingPolicy($parent->changeTrackingPolicy);

            if ($parent->isMappedSuperclass) {
                $classMetadata->setCustomRepositoryClassName($parent->getCustomRepositoryClassName());
            }
        }

        // Invoke driver
        try {
            $this->driver->loadMetadataForClass($classMetadata->getClassName(), $classMetadata, $metadataBuildingContext);
        } catch (ReflectionException $e) {
            throw MappingException::reflectionFailure($classMetadata->getClassName(), $e);
        }

        $this->completeIdentifierGeneratorMappings($classMetadata);

        if ($parent) {
            if ($parent->getCache()) {
                $classMetadata->setCache(clone $parent->getCache());
            }

            if (! empty($parent->entityListeners) && empty($classMetadata->entityListeners)) {
                $classMetadata->entityListeners = $parent->entityListeners;
            }
        }

        $this->completeRuntimeMetadata($classMetadata, $parent);

        if ($this->evm->hasListeners(Events::loadClassMetadata)) {
            $eventArgs = new LoadClassMetadataEventArgs($classMetadata, $this->em);

            $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
        }

        $this->buildValueGenerationPlan($classMetadata);
        $this->validateRuntimeMetadata($classMetadata, $parent);

        return $classMetadata;
    }
1328696
final public function &getColumnsMetadata($tableName)
    {
        if ( ! isset(self::$columns[$tableName])) {
            /* @noinspection PhpUnhandledExceptionInspection */
            self::$columns[$tableName] = (static::$useCacheForMetadata
                ? $this->retrieveColumnsCachedMetadata($tableName)
                : $this->retrieveColumnsMetadata($tableName)
            );
        }

        return self::$columns[$tableName];
    }
1343834
private function convertRelations($className, array $model, ClassMetadataInfo $metadata)
    {
        if (empty($model['relations'])) {
            return;
        }

        foreach ($model['relations'] as $name => $relation) {
            if ( ! isset($relation['alias'])) {
                $relation['alias'] = $name;
            }
            if ( ! isset($relation['class'])) {
                $relation['class'] = $name;
            }
            if ( ! isset($relation['local'])) {
                $relation['local'] = Inflector::tableize($relation['class']);
            }
            if ( ! isset($relation['foreign'])) {
                $relation['foreign'] = 'id';
            }
            if ( ! isset($relation['foreignAlias'])) {
                $relation['foreignAlias'] = $className;
            }

            if (isset($relation['refClass'])) {
                $type = 'many';
                $foreignType = 'many';
                $joinColumns = array();
            } else {
                $type = isset($relation['type']) ? $relation['type'] : 'one';
                $foreignType = isset($relation['foreignType']) ? $relation['foreignType'] : 'many';
                $joinColumns = array(
                    array(
                        'name' => $relation['local'],
                        'referencedColumnName' => $relation['foreign'],
                        'onDelete' => isset($relation['onDelete']) ? $relation['onDelete'] : null,
                    )
                );
            }

            if ($type == 'one' && $foreignType == 'one') {
                $method = 'mapOneToOne';
            } elseif ($type == 'many' && $foreignType == 'many') {
                $method = 'mapManyToMany';
            } else {
                $method = 'mapOneToMany';
            }

            $associationMapping = array();
            $associationMapping['fieldName'] = $relation['alias'];
            $associationMapping['targetEntity'] = $relation['class'];
            $associationMapping['mappedBy'] = $relation['foreignAlias'];
            $associationMapping['joinColumns'] = $joinColumns;

            $metadata->$method($associationMapping);
        }
    }
290035
final protected function getMetadata($name)
    {
        return isset($this->metadata[$name]) ? $this->metadata[$name] : null;
    }
1215001
public function loadMetadataForClass($className, ClassMetadataInterface $class)
    {
        /** @var $class ClassMetadata */
        $reflection     = $class->getReflectionClass();
        $documentAnnots = [];
        $indexes        = [];

        //class annotations
        $classAnnotations = $this->reader->getClassAnnotations($reflection);
        foreach ($classAnnotations as $annot) {
            //document annotations
            $classAnnotations[get_class($annot)] = $annot;

            foreach ($this->entityAnnotationClasses as $annotClass => $i) {
                if ($annot instanceof $annotClass) {
                    $documentAnnots[$i] = $annot;
                    continue 2;
                }
            }

            //non-document class annotations
            if ($annot instanceof ODM\Discriminator) {
                if ($annot->attribute !== null) {
                    $class->setDiscriminatorAttribute($annot->attribute);
                }
                if ($annot->map !== null) {
                    $class->setDiscriminatorMap($annot->map);
                }
                if ($annot->defaultValue !== null) {
                    $class->setDiscriminatorDefaultValue($annot->defaultValue);
                }
            } elseif ($annot instanceof ODM\InheritanceType) {
                $class->setInheritanceType(constant(ClassMetadata::class . '::INHERITANCE_TYPE_' . $annot->value));
            } elseif ($annot instanceof ODM\Index) {
                $indexes[$annot->name]['projectionType'] = $annot->projectionType;
                $indexes[$annot->name]['readCapacity']   = $annot->readCapacity;
                $indexes[$annot->name]['writeCapacity']  = $annot->writeCapacity;
            } elseif ($annot instanceof ODM\ChangeTrackingPolicy) {
                $class->setChangeTrackingPolicy(constant(ClassMetadata::class . '::CHANGETRACKING_' . $annot->value));
            }
        }

        if (!$documentAnnots) {
            throw new MappingExceptionClassNotMapped($className);
        }

        //find the winning document annotation
        ksort($documentAnnots);
        $documentAnnot = reset($documentAnnots);

        if ($documentAnnot instanceof ODM\MappedSuperclass) {
            $class->isMappedSuperclass = true;
        } elseif ($documentAnnot instanceof ODM\EmbeddedDocument) {
            $class->isEmbeddedDocument = true;
        }
        if (isset($documentAnnot->table)) {
            $class->setTable($documentAnnot->table);
        }
        if (isset($documentAnnot->repositoryClass) && !$class->isEmbeddedDocument) {
            $class->setCustomRepositoryClass($documentAnnot->repositoryClass);
        }
        if (isset($documentAnnot->requireIndexes)) {
            $class->setRequireIndexes($documentAnnot->requireIndexes);
        }
        if (!empty($documentAnnot->readOnly)) {
            $class->markReadOnly();
        }

        //property annotations
        $propertyFactory = new PropertyMetadataFactory($class);
        foreach ($reflection->getProperties() as $property) {
            if (!$this->propertyNeedsMapping($class, $property)) {
                continue;
            }

            $mapping        = $propertyFactory->create($property->getName());
            $attributeAnnot = null;

            foreach ($this->reader->getPropertyAnnotations($property) as $annot) {
                if ($annot instanceof ODM\AbstractAttribute) {
                    $attributeAnnot         = true;
                    $mapping->attributeName = $annot->name;

                    if ($annot instanceof ODM\NotSaved) {
                        $mapping->notSaved = true;
                        continue;
                    }

                    $mapping->nullable = $annot->nullable;
                    $mapping->strategy = $annot->strategy;
                    $mapping->type     = $annot->type;

                    if ($class->isEmbeddedDocument && $mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET) {
                        throw MappingException::addToSetOnEmbeddedDocument($class->name, $property->getName());
                    }

                    if ($annot instanceof ODM\AbstractEmbed) {
                        $mapping->embedded       = $annot->embedded;
                        $mapping->targetDocument = $annot->targetDocument;

                        if ($annot instanceof ODM\EmbedMany) {
                            $mapping->collectionClass = $annot->collectionClass;
                        }
                    } elseif ($annot instanceof ODM\AbstractReference) {
                        $mapping->criteria         = $annot->criteria;
                        $mapping->inversedBy       = $annot->inversedBy;
                        $mapping->mappedBy         = $annot->mappedBy;
                        $mapping->mappedIndex      = $annot->mappedIndex;
                        $mapping->orphanRemoval    = $annot->orphanRemoval;
                        $mapping->reference        = $annot->reference;
                        $mapping->requireIndexes   = $annot->requireIndexes;
                        $mapping->repositoryMethod = $annot->repositoryMethod;
                        $mapping->storeAs          = $annot->storeAs;
                        $mapping->targetDocument   = $annot->targetDocument;

                        if ($annot instanceof ODM\ReferenceMany) {
                            $mapping->limit           = $annot->limit;
                            $mapping->prime           = $annot->prime;
                            $mapping->collectionClass = $annot->collectionClass;

                            if ($annot->order === PropertyMetadata::ORDER_REVERSE) {
                                $mapping->reverse = true;
                            }
                        }

                        $mapping->setCascades((array)$annot->cascade);
                    }
                } elseif ($annot instanceof ODM\HashKey) {
                    $indexes[$annot->index]['hashKey'] = new HashKey($mapping);
                } elseif ($annot instanceof ODM\RangeKey) {
                    $indexes[$annot->index]['rangeKey'] = new RangeKey($mapping);
                } elseif ($annot instanceof ODM\Project) {
                    $value = (array)$annot->value;

                    if (count($value) === 0) {
                        //if no name is specified the primary index is assumed
                        $indexes[null]['projectionAttributes'][] = $property->getName();
                    } else {
                        foreach ($value as $indexName) {
                            $indexes[$indexName]['projectionAttributes'][] = $property->getName();
                        }
                    }
                } elseif ($annot instanceof ODM\GeneratedValue) {
                    $mapping->generatorStrategy = $annot->strategy;
                    $mapping->generatorOptions  = $annot->options;
                } elseif ($annot instanceof ODM\Discriminator) {
                    $mapping->discriminatorAttribute    = $annot->attribute;
                    $mapping->discriminatorMap          = $annot->map;
                    $mapping->discriminatorDefaultValue = $annot->defaultValue;
                } elseif ($annot instanceof ODM\AlsoLoad) {
                    $mapping->alsoLoadAttributes = (array)$annot->value;
                } elseif ($annot instanceof ODM\Version) {
                    $mapping->version = true;
                } elseif ($annot instanceof ODM\Lock) {
                    $mapping->lock = true;
                } elseif ($annot instanceof ODM\ChangeTrackingPolicy) {
                    $class->setChangeTrackingPolicy(constant(ClassMetadata::class . '::CHANGETRACKING_' . $annot->value));
                }
            }

            if ($attributeAnnot) {
                $mapping->mapAttribute($class);
            }
        }

        //method annotations
        foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            /* Filter for the declaring class only. Callbacks from parent
             * classes will already be registered.
             */
            if ($method->getDeclaringClass()->name !== $reflection->name) {
                continue;
            }

            foreach ($this->reader->getMethodAnnotations($method) as $annot) {
                if ($annot instanceof ODM\AlsoLoad) {
                    $class->registerAlsoLoadMethod($method->getName(), $annot->value);
                }

                if (!isset($classAnnotations[ODM\HasLifecycleCallbacks::class])) {
                    continue;
                }

                if ($annot instanceof ODM\PrePersist) {
                    $class->addLifecycleCallback($method->getName(), Event::prePersist);
                } elseif ($annot instanceof ODM\PostPersist) {
                    $class->addLifecycleCallback($method->getName(), Event::postPersist);
                } elseif ($annot instanceof ODM\PreUpdate) {
                    $class->addLifecycleCallback($method->getName(), Event::preUpdate);
                } elseif ($annot instanceof ODM\PostUpdate) {
                    $class->addLifecycleCallback($method->getName(), Event::postUpdate);
                } elseif ($annot instanceof ODM\PreRemove) {
                    $class->addLifecycleCallback($method->getName(), Event::preRemove);
                } elseif ($annot instanceof ODM\PostRemove) {
                    $class->addLifecycleCallback($method->getName(), Event::postRemove);
                } elseif ($annot instanceof ODM\PreLoad) {
                    $class->addLifecycleCallback($method->getName(), Event::preLoad);
                } elseif ($annot instanceof ODM\PostLoad) {
                    $class->addLifecycleCallback($method->getName(), Event::postLoad);
                } elseif ($annot instanceof ODM\PreFlush) {
                    $class->addLifecycleCallback($method->getName(), Event::preFlush);
                }
            }
        }

        //indexes
        $indexFactory = new IndexFactory($class);
        foreach ($indexes as $name => $annot) {
            $primary = $name === '';

            //create index, merging values collected from annotations with defaults
            $opts                  = array_fill_keys(['hashKey', 'rangeKey', 'projectionType', 'projectionAttributes'], null);
            $opts['readCapacity']  = IndexFactory::DEFAULT_READ_CAPACITY;
            $opts['writeCapacity'] = IndexFactory::DEFAULT_WRITE_CAPACITY;
            $opts                  = array_merge($opts, $annot);

            $index = $indexFactory->create(
                $primary ? null : $name,
                $opts['hashKey'],
                $opts['rangeKey'],
                $opts['projectionType'],
                $opts['projectionAttributes'],
                $opts['readCapacity'],
                $opts['writeCapacity']
            );

            if ($primary === true) {
                $class->setIndex($index);
            } else {
                $class->addSecondaryIndex($index);
            }
        }
    }
458871
private function buildIndexes(ClassMetadataInfo $metadata)
    {
        $tableName = $metadata->table['name'];
        $indexes   = $this->tables[$tableName]->getIndexes();

        foreach($indexes as $index){
            if ($index->isPrimary()) {
                continue;
            }

            $indexName      = $index->getName();
            $indexColumns   = $index->getColumns();
            $constraintType = $index->isUnique()
                ? 'uniqueConstraints'
                : 'indexes';

            $metadata->table[$constraintType][$indexName]['columns'] = $indexColumns;
        }
    }
844080
public function getMetadata($className, $subset)
	{
		$classMetadataCacheKey = $this->getClassMetadataCacheKey($className);
		$classMetadata = $this->cacheStorage->getItem($classMetadataCacheKey);
		if ($classMetadata === null)
		{
			$classMetadata = $this->readClassMetadata($className);
			$this->cacheStorage->addItem($classMetadataCacheKey, $classMetadata);
		}
		if (!is_array($classMetadata))
		{
			throw new \LogicException(sprintf('Invalid metadata for class %s.', $className));
		}
		if (!isset($classMetadata[$subset]))
		{
			throw new \LogicException(sprintf('No metadata for subset "%s" in class %s.', $subset, $className));
		}
		$subsetMetadata = $classMetadata[$subset];
		if (!($subsetMetadata instanceof DT\Metadata))
		{
			throw new \LogicException(sprintf('Invalid metadata for subset "%s" in class %s.', $subset, $className));
		}
		return $subsetMetadata;
	}
822922
private function convertColumns($className, array $model, ClassMetadataInfo $metadata)
    {
        $id = false;

        if (isset($model['columns']) && $model['columns']) {
            foreach ($model['columns'] as $name => $column) {
                $fieldMapping = $this->convertColumn($className, $name, $column, $metadata);

                if (isset($fieldMapping['id']) && $fieldMapping['id']) {
                    $id = true;
                }
            }
        }

        if ( ! $id) {
            $fieldMapping = array(
                'fieldName' => 'id',
                'columnName' => 'id',
                'type' => 'integer',
                'id' => true
            );
            $metadata->mapField($fieldMapping);
            $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
        }
    }
674460
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        /**
         * This is the actual type we have at this point, but we cannot change the
         * signature due to inheritance.
         *
         * @var ORM\ClassMetadata $metadata
         */

        try {
            $class = $metadata->getReflectionClass();
            $classSchema = $this->getClassSchema($class->getName());
            $classAnnotations = $this->reader->getClassAnnotations($class);
        } catch (ClassSchemaNotFoundException $exception) {
            throw new ORM\MappingException(sprintf('Failure while fetching class schema class "%s": %s', $metadata->getName(), $exception->getMessage()), 1542792708, $exception);
        }

        // Evaluate Entity annotation
        if (isset($classAnnotations[ORM\MappedSuperclass::class])) {
            $mappedSuperclassAnnotation = $classAnnotations[ORM\MappedSuperclass::class];
            if ($mappedSuperclassAnnotation->repositoryClass !== null) {
                $metadata->setCustomRepositoryClass($mappedSuperclassAnnotation->repositoryClass);
            }
            $metadata->isMappedSuperclass = true;
        } elseif (isset($classAnnotations[Flow\Entity::class]) || isset($classAnnotations[ORM\Entity::class])) {
            $entityAnnotation = isset($classAnnotations[Flow\Entity::class]) ? $classAnnotations[Flow\Entity::class] : $classAnnotations[ORM\Entity::class];
            if ($entityAnnotation->repositoryClass !== null) {
                $metadata->setCustomRepositoryClass($entityAnnotation->repositoryClass);
            } elseif ($classSchema->getRepositoryClassName() !== null) {
                if ($this->reflectionService->isClassImplementationOf($classSchema->getRepositoryClassName(), \Doctrine\ORM\EntityRepository::class)) {
                    $metadata->setCustomRepositoryClass($classSchema->getRepositoryClassName());
                }
            }
            if ($entityAnnotation->readOnly) {
                $metadata->markReadOnly();
            }
        } elseif (isset($classAnnotations[Flow\ValueObject::class])) {
            $valueObjectAnnotation = $classAnnotations[Flow\ValueObject::class];
            if ($valueObjectAnnotation->embedded === true) {
                $metadata->isEmbeddedClass = true;
            } else {
                // also ok... but we make it read-only
                $metadata->markReadOnly();
            }
        } elseif (isset($classAnnotations[ORM\Embeddable::class])) {
            $metadata->isEmbeddedClass = true;
        } else {
            throw ORM\MappingException::classIsNotAValidEntityOrMappedSuperClass($className);
        }

        // Evaluate Table annotation
        $primaryTable = [];
        if (isset($classAnnotations[ORM\Table::class])) {
            $tableAnnotation = $classAnnotations[ORM\Table::class];
            $primaryTable = [
                'name' => $tableAnnotation->name,
                'schema' => $tableAnnotation->schema
            ];

            if ($tableAnnotation->indexes !== null) {
                foreach ($tableAnnotation->indexes as $indexAnnotation) {
                    $index = ['columns' => $indexAnnotation->columns];
                    if (!empty($indexAnnotation->flags)) {
                        $index['flags'] = $indexAnnotation->flags;
                    }
                    if (!empty($indexAnnotation->options)) {
                        $index['options'] = $indexAnnotation->options;
                    }
                    if (!empty($indexAnnotation->name)) {
                        $primaryTable['indexes'][$indexAnnotation->name] = $index;
                    } else {
                        $primaryTable['indexes'][] = $index;
                    }
                }
            }

            if ($tableAnnotation->uniqueConstraints !== null) {
                foreach ($tableAnnotation->uniqueConstraints as $uniqueConstraint) {
                    $uniqueConstraint = ['columns' => $uniqueConstraint->columns];
                    if (!empty($uniqueConstraint->options)) {
                        $uniqueConstraint['options'] = $uniqueConstraint->options;
                    }
                    if (!empty($uniqueConstraint->name)) {
                        $primaryTable['uniqueConstraints'][$uniqueConstraint->name] = $uniqueConstraint;
                    } else {
                        $primaryTable['uniqueConstraints'][] = $uniqueConstraint;
                    }
                }
            }

            if ($tableAnnotation->options !== null) {
                $primaryTable['options'] = $tableAnnotation->options;
            }
        }
        if (!isset($classAnnotations[ORM\Embeddable::class])
            && !isset($primaryTable['name'])) {
            $className = $classSchema->getClassName();
            $primaryTable['name'] = $this->inferTableNameFromClassName($className);
        }

        // Evaluate @Cache annotation
        if (isset($classAnnotations[ORM\Cache::class])) {
            $cacheAnnotation = $classAnnotations[ORM\Cache::class];
            $cacheMap   = [
                'region' => $cacheAnnotation->region,
                'usage'  => constant('Doctrine\ORM\Mapping\ClassMetadata::CACHE_USAGE_' . $cacheAnnotation->usage),
            ];

            $metadata->enableCache($cacheMap);
        }

        // Evaluate NamedNativeQueries annotation
        if (isset($classAnnotations[ORM\NamedNativeQueries::class])) {
            $namedNativeQueriesAnnotation = $classAnnotations[ORM\NamedNativeQueries::class];

            foreach ($namedNativeQueriesAnnotation->value as $namedNativeQuery) {
                $metadata->addNamedNativeQuery([
                    'name' => $namedNativeQuery->name,
                    'query' => $namedNativeQuery->query,
                    'resultClass' => $namedNativeQuery->resultClass,
                    'resultSetMapping' => $namedNativeQuery->resultSetMapping,
                ]);
            }
        }

        // Evaluate SqlResultSetMappings annotation
        if (isset($classAnnotations[ORM\SqlResultSetMappings::class])) {
            $sqlResultSetMappingsAnnotation = $classAnnotations[ORM\SqlResultSetMappings::class];

            foreach ($sqlResultSetMappingsAnnotation->value as $resultSetMapping) {
                $entities = [];
                $columns = [];
                foreach ($resultSetMapping->entities as $entityResultAnnotation) {
                    $entityResult = [
                        'fields' => [],
                        'entityClass' => $entityResultAnnotation->entityClass,
                        'discriminatorColumn' => $entityResultAnnotation->discriminatorColumn,
                    ];

                    foreach ($entityResultAnnotation->fields as $fieldResultAnnotation) {
                        $entityResult['fields'][] = [
                            'name' => $fieldResultAnnotation->name,
                            'column' => $fieldResultAnnotation->column
                        ];
                    }

                    $entities[] = $entityResult;
                }

                foreach ($resultSetMapping->columns as $columnResultAnnotation) {
                    $columns[] = [
                        'name' => $columnResultAnnotation->name,
                    ];
                }

                $metadata->addSqlResultSetMapping([
                    'name' => $resultSetMapping->name,
                    'entities' => $entities,
                    'columns' => $columns
                ]);
            }
        }

        // Evaluate NamedQueries annotation
        if (isset($classAnnotations[ORM\NamedQueries::class])) {
            $namedQueriesAnnotation = $classAnnotations[ORM\NamedQueries::class];

            if (!is_array($namedQueriesAnnotation->value)) {
                throw new \UnexpectedValueException('@ORM\NamedQueries should contain an array of @ORM\NamedQuery annotations.');
            }

            foreach ($namedQueriesAnnotation->value as $namedQuery) {
                if (!($namedQuery instanceof ORM\NamedQuery)) {
                    throw new \UnexpectedValueException('@ORM\NamedQueries should contain an array of @ORM\NamedQuery annotations.');
                }
                $metadata->addNamedQuery([
                    'name' => $namedQuery->name,
                    'query' => $namedQuery->query
                ]);
            }
        }

        // Evaluate InheritanceType annotation
        if (isset($classAnnotations[ORM\InheritanceType::class])) {
            $inheritanceTypeAnnotation = $classAnnotations[ORM\InheritanceType::class];
            $inheritanceType = constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . strtoupper($inheritanceTypeAnnotation->value));

            if ($inheritanceType !== ORM\ClassMetadata::INHERITANCE_TYPE_NONE) {

                // Evaluate DiscriminatorColumn annotation
                if (isset($classAnnotations[ORM\DiscriminatorColumn::class])) {
                    $discriminatorColumnAnnotation = $classAnnotations[ORM\DiscriminatorColumn::class];
                    $discriminatorColumn = [
                        'name' => $discriminatorColumnAnnotation->name,
                        'type' => $discriminatorColumnAnnotation->type,
                        'length' => $discriminatorColumnAnnotation->length,
                        'columnDefinition' => $discriminatorColumnAnnotation->columnDefinition
                    ];
                } else {
                    $discriminatorColumn = [
                        'name' => 'dtype', 'type' => 'string', 'length' => 255
                    ];
                }

                // Evaluate DiscriminatorMap annotation
                if (isset($classAnnotations[ORM\DiscriminatorMap::class])) {
                    $discriminatorMapAnnotation = $classAnnotations[ORM\DiscriminatorMap::class];
                    $discriminatorMap = $discriminatorMapAnnotation->value;
                } else {
                    $discriminatorMap = [];
                    $subclassNames = $this->reflectionService->getAllSubClassNamesForClass($className);
                    if (!$this->reflectionService->isClassAbstract($className)) {
                        $mappedClassName = strtolower(str_replace('Domain_Model_', '', str_replace('\\', '_', $className)));
                        $discriminatorMap[$mappedClassName] = $className;
                    }
                    foreach ($subclassNames as $subclassName) {
                        $mappedSubclassName = strtolower(str_replace('Domain_Model_', '', str_replace('\\', '_', $subclassName)));
                        $discriminatorMap[$mappedSubclassName] = $subclassName;
                    }
                }

                if ($discriminatorMap !== []) {
                    $metadata->setDiscriminatorColumn($discriminatorColumn);
                    $metadata->setDiscriminatorMap($discriminatorMap);
                } else {
                    $inheritanceType = ORM\ClassMetadata::INHERITANCE_TYPE_NONE;
                }
            }

            $metadata->setInheritanceType($inheritanceType);
        }

        // Evaluate DoctrineChangeTrackingPolicy annotation
        if (isset($classAnnotations[ORM\ChangeTrackingPolicy::class])) {
            $changeTrackingAnnotation = $classAnnotations[ORM\ChangeTrackingPolicy::class];
            $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . strtoupper($changeTrackingAnnotation->value)));
        } else {
            $metadata->setChangeTrackingPolicy(ORM\ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT);
        }

        // Evaluate annotations on properties/fields
        try {
            $this->evaluatePropertyAnnotations($metadata);
        } catch (ORM\MappingException $exception) {
            throw new ORM\MappingException(sprintf('Failure while evaluating property annotations for class "%s": %s', $metadata->getName(), $exception->getMessage()), 1382003497, $exception);
        }

        // build unique index for table
        if (!isset($classAnnotations[ORM\Embeddable::class])
            && !isset($primaryTable['uniqueConstraints'])) {
            $idProperties = array_keys($classSchema->getIdentityProperties());
            if (array_diff($idProperties, $metadata->getIdentifierFieldNames()) !== []) {
                $uniqueIndexName = $this->truncateIdentifier('flow_identity_' . $primaryTable['name']);
                foreach ($idProperties as $idProperty) {
                    $primaryTable['uniqueConstraints'][$uniqueIndexName]['columns'][] = isset($metadata->columnNames[$idProperty]) ? $metadata->columnNames[$idProperty] : strtolower($idProperty);
                }
            }
        }

        $metadata->setPrimaryTable($primaryTable);

        // Evaluate AssociationOverrides annotation
        $this->evaluateOverridesAnnotations($classAnnotations, $metadata);

        // Evaluate EntityListeners annotation
        $this->evaluateEntityListenersAnnotation($class, $metadata, $classAnnotations);

        // Evaluate @HasLifecycleCallbacks annotation
        $this->evaluateLifeCycleAnnotations($class, $metadata);
    }
1354643
private function convertColumnAnnotationToFieldMetadata(string $tableName, Column $column, string $fieldName)
    {
        $options       = [];
        $fieldMetadata = new Mapping\FieldMetadata($fieldName);

        $fieldMetadata->setType($column->getType());
        $fieldMetadata->setTableName($tableName);
        $fieldMetadata->setColumnName($column->getName());

        // Type specific elements
        switch ($column->getType()->getName()) {
            case Type::TARRAY:
            case Type::BLOB:
            case Type::GUID:
            case Type::JSON_ARRAY:
            case Type::OBJECT:
            case Type::SIMPLE_ARRAY:
            case Type::STRING:
            case Type::TEXT:
                if ($column->getLength()) {
                    $fieldMetadata->setLength($column->getLength());
                }

                $options['fixed'] = $column->getFixed();
                break;

            case Type::DECIMAL:
            case Type::FLOAT:
                $fieldMetadata->setScale($column->getScale());
                $fieldMetadata->setPrecision($column->getPrecision());
                break;

            case Type::INTEGER:
            case Type::BIGINT:
            case Type::SMALLINT:
                $options['unsigned'] = $column->getUnsigned();
                break;
        }

        // Comment
        $comment = $column->getComment();
        if ($comment !== null) {
            $options['comment'] = $comment;
        }

        // Default
        $default = $column->getDefault();
        if ($default !== null) {
            $options['default'] = $default;
        }

        $fieldMetadata->setOptions($options);

        return $fieldMetadata;
    }
382542
protected function processFile($column, $file, $filename, $name = null)
  {
    if (!is_file($file)) {
      Exception::ThrowError(Exception::FILE_NOT_EXISTS, $file);
    }

    $ext  = strtolower(pathinfo($file, PATHINFO_EXTENSION));
    $size = filesize($file);

    $this->copyFile($file, $this->getFilesPath() . $filename);

    return $this->setSerialized(
      $column,
      array(
        'file'      => $filename,
        'extension' => $ext,
        'size'      => $size,
        'name'      => $name,
      )
    );
  }
202862
public function getFieldTypeFor($name, $column, $field = null)
    {
        $type = null;
        if ($column instanceof Column) {
            if ($column->getType()) {
                $type = get_class($column->getType());
            }
            $column = $column->getName();
        }
        if ($field !== null) {
            if (isset($this->contenttypes[$name]) && isset($this->contenttypes[$name]['fields'][$column]['fields'][$field])) {
                $type = $this->contenttypes[$name]['fields'][$column]['fields'][$field]['type'];
            }
        } elseif (isset($this->contenttypes[$name]) && isset($this->contenttypes[$name]['fields'][$column])) {
            $type = $this->contenttypes[$name]['fields'][$column]['type'];
        }

        if ($column === 'slug') {
            $type = 'slug';
        }

        if ($type === 'select' && isset($this->contenttypes[$name]['fields'][$column]['multiple']) && $this->contenttypes[$name]['fields'][$column]['multiple'] === true) {
            $type = 'selectmultiple';
        }

        if ($type && isset($this->typemap[$type])) {
            $type = $this->typemap[$type];
        } else {
            $type = $this->typemap['text'];
        }

        return $type;
    }
39785
public static function getMethodAnnotations($className, $methodName, $annotationClassName = null)
    {
        if(!isset(static::$annotations[$className]['Methods'][$methodName]))
        {
            return [];
        }
        if(null === $annotationClassName)
        {
            return static::$annotations[$className]['Methods'][$methodName];
        }
        else
        {
            $result = [];
            foreach(static::$annotations[$className]['Methods'][$methodName] as $annotation)
            {
                if($annotation instanceof $annotationClassName)
                {
                    $result[] = $annotation;
                }
            }
            return $result;
        }
    }
267728
public function getMetadatum($name)
        {
            if (array_key_exists($name, $this->metadata)) {
                return $this->metadata[$name];
            }
            return null;
        }