Returns schema code based on its class name.
@param null|string $schemaClass
@return string
@since 3.1
355966
public static function identifySchema(?string $schemaClass): string
    {
        switch ($schemaClass) {
            case 'yii\db\mssql\Schema':
                return self::SCHEMA_MSSQL;

            case 'yii\db\oci\Schema':
                return self::SCHEMA_OCI;

            case 'yii\db\pgsql\Schema':
                return self::SCHEMA_PGSQL;

            case 'yii\db\sqlite\Schema':
                return self::SCHEMA_SQLITE;

            case 'yii\db\cubrid\Schema':
                return self::SCHEMA_CUBRID;

            case 'yii\db\mysql\Schema':
                return self::SCHEMA_MYSQL;

            default:
                return self::SCHEMA_UNSUPPORTED;
        }
    }
458489
public function fullyQualifiedName($class)
    {
        if ($this->namespace) {
            $namespace = str_replace('\\\\', '\\', '\\' . $this->namespace . '\\');
        } else {
            $namespace = '\\'; // global namespace
        }

        if ($this->class === null) {
            $this->class = '';
        }

        if ($class === null) {
            return '';
        }

        if (strcasecmp($class, $this->class) === 0) {
            return $namespace . $this->class;
        }
        $pos = strpos($class, '\\');
        if ($pos !== false) {
            if ($pos === 0) {
                // Fully qualified name (\Foo\Bar)
                return $class;
            }
            // Qualified name (Foo\Bar)
            if ($this->uses) {
                foreach ($this->uses as $alias => $aliasedNamespace) {
                    $alias .= '\\';
                    if (strcasecmp(substr($class, 0, strlen($alias)), $alias) === 0) {
                        // Aliased namespace (use \Long\Namespace as Foo)
                        return '\\' . $aliasedNamespace . substr($class, strlen($alias) - 1);
                    }
                }
            }
        } elseif ($this->uses) {
            // Unqualified name (Foo)
            foreach ($this->uses as $alias => $aliasedNamespace) {
                if (strcasecmp($alias, $class) === 0) {
                    return '\\' . $aliasedNamespace;
                }
            }
        }

        return $namespace . $class;
    }
1000226
public function getSchema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = new Schema($this);
        }

        return $this->schema;
    }
569053
public function get($schemaId)
    {
        $class = $this->getSchemaClass();
        $data = static::$schemas[$schemaId];
        /** @var Schema $schema */
        $schema = call_user_func([$class, 'deserializeObject'], $data);
        $schema->getMeta()->setLocation($this->schemasEndpointUrl.$schemaId);

        return $schema;
    }
444756
public static function loadClass($class)
    {
        if (isset(self::$_classMap[$class]))
            return (bool)require sprintf('%s/%s', self::ROOT_DIR, self::$_classMap[$class]);
        return null;
    }
450121
public function getSchemaFromMetadata(array $classes)
    {
        // Reminder for processed classes, used for hierarchies
        $processedClasses     = [];
        $eventManager         = $this->em->getEventManager();
        $schemaManager        = $this->em->getConnection()->getSchemaManager();
        $metadataSchemaConfig = $schemaManager->createSchemaConfig();

        $metadataSchemaConfig->setExplicitForeignKeyIndexes(false);
        $schema = new Schema([], [], $metadataSchemaConfig);

        $addedFks       = [];
        $blacklistedFks = [];

        foreach ($classes as $class) {
            /** @var ClassMetadata $class */
            if ($this->processingNotRequired($class, $processedClasses)) {
                continue;
            }

            $table = $schema->createTable($class->table->getQuotedQualifiedName($this->platform));

            switch ($class->inheritanceType) {
                case InheritanceType::SINGLE_TABLE:
                    $this->gatherColumns($class, $table);
                    $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);

                    // Add the discriminator column
                    $this->addDiscriminatorColumnDefinition($class, $table);

                    // Aggregate all the information from all classes in the hierarchy
                    $parentClass = $class;

                    while (($parentClass = $parentClass->getParent()) !== null) {
                        // Parent class information is already contained in this class
                        $processedClasses[$parentClass->getClassName()] = true;
                    }

                    foreach ($class->getSubClasses() as $subClassName) {
                        $subClass = $this->em->getClassMetadata($subClassName);

                        $this->gatherColumns($subClass, $table);
                        $this->gatherRelationsSql($subClass, $table, $schema, $addedFks, $blacklistedFks);

                        $processedClasses[$subClassName] = true;
                    }

                    break;

                case InheritanceType::JOINED:
                    // Add all non-inherited fields as columns
                    $pkColumns = [];

                    foreach ($class->getDeclaredPropertiesIterator() as $fieldName => $property) {
                        if (! ($property instanceof FieldMetadata)) {
                            continue;
                        }

                        if (! $class->isInheritedProperty($fieldName)) {
                            $columnName = $this->platform->quoteIdentifier($property->getColumnName());

                            $this->gatherColumn($class, $property, $table);

                            if ($class->isIdentifier($fieldName)) {
                                $pkColumns[] = $columnName;
                            }
                        }
                    }

                    $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);

                    // Add the discriminator column only to the root table
                    if ($class->isRootEntity()) {
                        $this->addDiscriminatorColumnDefinition($class, $table);
                    } else {
                        // Add an ID FK column to child tables
                        $inheritedKeyColumns = [];

                        foreach ($class->identifier as $identifierField) {
                            $idProperty = $class->getProperty($identifierField);

                            if ($class->isInheritedProperty($identifierField)) {
                                $column     = $this->gatherColumn($class, $idProperty, $table);
                                $columnName = $column->getQuotedName($this->platform);

                                // TODO: This seems rather hackish, can we optimize it?
                                $column->setAutoincrement(false);

                                $pkColumns[]           = $columnName;
                                $inheritedKeyColumns[] = $columnName;
                            }
                        }

                        if (! empty($inheritedKeyColumns)) {
                            // Add a FK constraint on the ID column
                            $rootClass = $this->em->getClassMetadata($class->getRootClassName());

                            $table->addForeignKeyConstraint(
                                $rootClass->table->getQuotedQualifiedName($this->platform),
                                $inheritedKeyColumns,
                                $inheritedKeyColumns,
                                ['onDelete' => 'CASCADE']
                            );
                        }
                    }

                    $table->setPrimaryKey($pkColumns);

                    break;

                case InheritanceType::TABLE_PER_CLASS:
                    throw NotSupported::create();

                default:
                    $this->gatherColumns($class, $table);
                    $this->gatherRelationsSql($class, $table, $schema, $addedFks, $blacklistedFks);

                    break;
            }

            $pkColumns = [];

            foreach ($class->identifier as $identifierField) {
                $property = $class->getProperty($identifierField);

                if ($property instanceof FieldMetadata) {
                    $pkColumns[] = $this->platform->quoteIdentifier($property->getColumnName());

                    continue;
                }

                if ($property instanceof ToOneAssociationMetadata) {
                    foreach ($property->getJoinColumns() as $joinColumn) {
                        $pkColumns[] = $this->platform->quoteIdentifier($joinColumn->getColumnName());
                    }
                }
            }

            if (! $table->hasIndex('primary')) {
                $table->setPrimaryKey($pkColumns);
            }

            // there can be unique indexes automatically created for join column
            // if join column is also primary key we should keep only primary key on this column
            // so, remove indexes overruled by primary key
            $primaryKey = $table->getIndex('primary');

            foreach ($table->getIndexes() as $idxKey => $existingIndex) {
                if ($primaryKey->overrules($existingIndex)) {
                    $table->dropIndex($idxKey);
                }
            }

            if ($class->table->getIndexes()) {
                foreach ($class->table->getIndexes() as $indexName => $indexData) {
                    $indexName = is_numeric($indexName) ? null : $indexName;
                    $index     = new Index($indexName, $indexData['columns'], $indexData['unique'], $indexData['flags'], $indexData['options']);

                    foreach ($table->getIndexes() as $tableIndexName => $tableIndex) {
                        if ($tableIndex->isFullfilledBy($index)) {
                            $table->dropIndex($tableIndexName);
                            break;
                        }
                    }

                    if ($indexData['unique']) {
                        $table->addUniqueIndex($indexData['columns'], $indexName, $indexData['options']);
                    } else {
                        $table->addIndex($indexData['columns'], $indexName, $indexData['flags'], $indexData['options']);
                    }
                }
            }

            if ($class->table->getUniqueConstraints()) {
                foreach ($class->table->getUniqueConstraints() as $indexName => $indexData) {
                    $indexName = is_numeric($indexName) ? null : $indexName;
                    $uniqIndex = new Index($indexName, $indexData['columns'], true, false, $indexData['flags'], $indexData['options']);

                    foreach ($table->getIndexes() as $tableIndexName => $tableIndex) {
                        if ($tableIndex->isFullfilledBy($uniqIndex)) {
                            $table->dropIndex($tableIndexName);
                            break;
                        }
                    }

                    $table->addUniqueConstraint($indexData['columns'], $indexName, $indexData['flags'], $indexData['options']);
                }
            }

            if ($class->table->getOptions()) {
                foreach ($class->table->getOptions() as $key => $val) {
                    $table->addOption($key, $val);
                }
            }

            $processedClasses[$class->getClassName()] = true;

            foreach ($class->getDeclaredPropertiesIterator() as $property) {
                if (! $property instanceof FieldMetadata
                    || ! $property->hasValueGenerator()
                    || $property->getValueGenerator()->getType() !== GeneratorType::SEQUENCE
                    || $class->getClassName() !== $class->getRootClassName()) {
                    continue;
                }

                $quotedName = $this->platform->quoteIdentifier($property->getValueGenerator()->getDefinition()['sequenceName']);

                if (! $schema->hasSequence($quotedName)) {
                    $schema->createSequence($quotedName, $property->getValueGenerator()->getDefinition()['allocationSize']);
                }
            }

            if ($eventManager->hasListeners(ToolEvents::postGenerateSchemaTable)) {
                $eventManager->dispatchEvent(
                    ToolEvents::postGenerateSchemaTable,
                    new GenerateSchemaTableEventArgs($class, $schema, $table)
                );
            }
        }

        if (! $this->platform->supportsSchemas() && ! $this->platform->canEmulateSchemas()) {
            $schema->visit(new RemoveNamespacedAssets());
        }

        if ($eventManager->hasListeners(ToolEvents::postGenerateSchema)) {
            $eventManager->dispatchEvent(
                ToolEvents::postGenerateSchema,
                new GenerateSchemaEventArgs($this->em, $schema)
            );
        }

        return $schema;
    }
155686
public function getClassSchema($classNameOrObject)
    {
        $className = $classNameOrObject;
        if (is_object($classNameOrObject)) {
            $className = TypeHandling::getTypeForValue($classNameOrObject);
        }
        $className = $this->cleanClassName($className);

        if (!isset($this->classSchemata[$className])) {
            $this->classSchemata[$className] = $this->classSchemataRuntimeCache->get($this->produceCacheIdentifierFromClassName($className));
        }

        return is_object($this->classSchemata[$className]) ? $this->classSchemata[$className] : null;
    }
579522
private function getFromCache(string $class): ?ClassMetadataInterface
    {
        if (null === $this->cache) {
            return null;
        }

        if ($this->cache instanceof Cache) {
            $cached = $this->cache->fetch($class) ?: null;
        } else {
            $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class));
            $item = $this->cache->getItem($class);
            $cached = $item->isHit() ? $item->get() : null;
        }

        return $cached;
    }
856493
public static function get_schema($name = 'default')
    {
        $connection = self::get_conn($name);
        if ($connection) {
            return $connection->getSchemaManager();
        }
        return null;
    }
956004
public function extractClassName()
    {
        $tokens = token_get_all($this->phpCode);
        $numberOfTokens = count($tokens);
        for ($i = 0; $i < $numberOfTokens; $i++) {
            $token = $tokens[$i];
            if (is_string($token) || $token[0] !== T_CLASS) {
                continue;
            }
            for (++$i; $i < $numberOfTokens; $i++) {
                $token = $tokens[$i];
                if (is_string($token)) {
                    break;
                }
                list($type, $value) = $token;
                if ($type === T_STRING) {
                    return $value;
                }
                if ($type !== T_WHITESPACE) {
                    break;
                }
            }
        }
        return null;
    }
928430
public static function classToName(string $class): string
    {
        $shortClassName = self::getShortClassName($class);
        $rawCommandName = Strings::substring($shortClassName, 0, -strlen('Command'));

        // ECSCommand => ecs
        for ($i = 0; $i < strlen($rawCommandName); ++$i) {
            if (ctype_upper($rawCommandName[$i]) && self::isFollowedByUpperCaseLetterOrNothing($rawCommandName, $i)) {
                $rawCommandName[$i] = strtolower($rawCommandName[$i]);
            } else {
                break;
            }
        }

        $rawCommandName = lcfirst($rawCommandName);

        return Strings::replace($rawCommandName, '#[A-Z]#', function (array $matches): string {
            return '-' . strtolower($matches[0]);
        });
    }
1365568
public function getCreateSchemaSql(array $classes)
    {
        $schema = $this->getSchemaFromMetadata($classes);

        return $schema->toSql($this->platform);
    }
1225971
private function get_file_name_from_class( $class ) {
		if ( 'classmap' === static::$autoload_type ) {
			$filtered_class_name = explode( '\\', $class );
			$class_filename      = end( $filtered_class_name );
			$class_filename      = str_replace( '_', '-', $class_filename );

			return static::$filename_prefix . $class_filename . '.php';
		} else {

			return $this->psr4_get_file_name_from_class( $class );
		}
	}
548659
public function getSchema($class)
    {
        $serializer = $this->get($class);

        if (method_exists($serializer, 'getSchema')) {
            $url = $serializer->getSchema();
            $path = explode('/', $url);
            $absolutePath = $this->rootDir.'/vendor/claroline/distribution/'
            .$path[1].'/'.$path[2].'/Resources/schemas/'.$path[3];

            return $this->loadSchema($absolutePath);
        }
    }
850526
public function getBundleName($class)
    {
        $reflector = new \ReflectionClass(get_class($class));

        return ($p1 = strpos($ns = $reflector->getNamespaceName(), '\\')) === false ? $ns :
            substr($ns, 0, ($p2 = strpos($ns, '\\', $p1 + 1)) === false ? strlen($ns) : $p2);
    }
1192700
public static function make($class)
    {
        if (!array_key_exists(
            'class',
            $class
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "'class' field has not been found for defining 'object' schema entry",
                400
            );
        }

        if (!class_exists($class['class'])) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "class {$class['class']} has not been defined",
                400
            );
        }

        if (!method_exists(
            $class['class'],
            'make'
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "a 'class' defined in the 'object' schema entry must have a make method",
                400
            );
        }

        $instance = new static(
            $class['class']
        );

        if (array_key_exists(
            'relationship',
            $class
        )) {
            $instance->setRelationship(Relationship::make($class['relationship']));
        }

        return $instance;
    }
1144492
private function psr4_get_file_name_from_class( $class ) {
		$class = strtolower( $class );
		if ( stristr( $class, '\\' ) ) {

			// If the first item is == the collection name, trim it off.
			$class = str_ireplace( static::$autoload_class_prefix, '', $class );

			// Maybe fix formatting underscores to dashes and double to single slashes.
			$class     = str_replace( [ '_', '\\' ], [ '-', '/' ], $class );
			$class     = explode( '/', $class );
			$file_name = &$class[ count( $class ) - 1 ];
			$file_name = static::$filename_prefix . $file_name . '.php';
			$file_path = join( DIRECTORY_SEPARATOR, $class );

			return $file_path;
		} else {
			return static::$filename_prefix . str_replace( '_', '-', $class ) . '.php';
		}
	}