@param SchemaDescriptor $a
@param SchemaDescriptor $b

@return bool
324783
public function isSameNamespace(SchemaDescriptor $a, SchemaDescriptor $b)
    {
        $ans = $this->generator->schemaToNativeNamespace($a);
        $bns = $this->generator->schemaToNativeNamespace($b);
        return $ans == $bns;
    }
764216
function loadSchemaTransformationRules( $schemaType )
    {
        $ini = eZINI::instance( 'dbschema.ini' );

        if ( !$ini )
        {
            eZDebug::writeError( "Error loading $schemaType schema transformation rules" );
            return false;
        }

        $transformationRules = array();

        if ( $ini->hasVariable( $schemaType, 'ColumnNameTranslation' ) )
            $transformationRules['column-name'] = $ini->variable( $schemaType, 'ColumnNameTranslation' );

        if ( $ini->hasVariable( $schemaType, 'ColumnTypeTranslation' ) )
        {
            $transformationRules['column-type'] = $ini->variable( $schemaType, 'ColumnTypeTranslation' );

            // substitute values like "type1;type2" with an appropriate arrays
            if ( is_array( $transformationRules['column-type'] ) )
            {
                foreach ( $transformationRules['column-type'] as $key => $val )
                {
                    $types = explode( ';', $val );
                    $transformationRules['column-type'][$key] = $types;
                }
            }
        }

        $indexTranslations = array();
        if ( $ini->hasVariable( $schemaType, 'IndexTranslation' ) )
        {
            $translations = $ini->variable( $schemaType, 'IndexTranslation' );
            foreach ( $translations as $combinedName => $translation )
            {
                list( $tableName, $indexName ) = explode( '.', $combinedName );
                $indexTranslations[$tableName][$indexName] = array();
                $fields = explode( ';', $translation );
                foreach ( $fields as $field )
                {
                    $entries = explode( '.', $field );
                    $fieldName = $entries[0];
                    $fieldData = array();
                    for ( $i = 1; $i < count( $entries ); ++$i )
                    {
                        list( $metaName, $metaValue ) = explode( '/', $entries[$i], 2 );
                        if ( is_numeric( $metaValue ) )
                            $metaValue = (int)$metaValue;
                        $fieldData[$metaName] = $metaValue;
                    }
                    $indexTranslations[$tableName][$indexName][$fieldName] = $fieldData;
                }
            }
        }
        $transformationRules['index-field'] = $indexTranslations;

        $tableTranslations = array();
        if ( $ini->hasVariable( $schemaType, 'TableOptionTranslation' ) )
        {
            $translations = $ini->variable( $schemaType, 'TableOptionTranslation' );
            foreach ( $translations as $tableName => $optionTexts )
            {
                $tableTranslations[$tableName] = array();
                $options = explode( ';', $optionTexts );
                $optionData = array();
                foreach ( $options as $option )
                {
                    list( $metaName, $metaValue ) = explode( '/', $option, 2 );
                    if ( is_numeric( $metaValue ) )
                        $metaValue = (int)$metaValue;
                    $optionData[$metaName] = $metaValue;
                    $tableTranslations[$tableName] = $optionData;
                }
            }
        }
        $transformationRules['table-option'] = $tableTranslations;

        if ( $ini->hasVariable( $schemaType, 'IndexNameTranslation' ) )
        {
            $tmpIdxNameTranslations = $ini->variable( $schemaType, 'IndexNameTranslation' );

            if ( is_array( $tmpIdxNameTranslations ) )
            {
                foreach ( $tmpIdxNameTranslations as $key => $val )
                {
                    list( $tableName, $genericIdxName ) = explode( '.', $key );
                    $localIdxName = $val;
                    if ( !$tableName || !$genericIdxName || !$localIdxName )
                    {
                        eZDebug::writeWarning( "Malformed index name translation rule: $key => $val" );
                        continue;
                    }
                    $transformationRules['index-name'][] = array( $tableName, $genericIdxName, $localIdxName );

                }
            }
            unset( $tmpIdxNameTranslations );
        }

        if ( $ini->hasVariable( $schemaType, 'ColumnOptionTranslations' ) )
        {
            $transformationRules['column-option'] = array();
            foreach( $ini->variable( $schemaType, 'ColumnOptionTranslations' ) as $key => $val )
            {
                list( $tableName, $colName ) = explode( '.', $key );
                $colOptOverride = $val;
                if ( !$tableName || !$colName || !$colOptOverride )
                {
                    eZDebug::writeWarning( "Malformed column option translation rule: $key => $val" );
                    continue;
                }
                $transformationRules['column-option'][] = array( $tableName, $colName, $colOptOverride );
            }
        }

        // prevent PHP warnings when cycling through the rules
        foreach ( array( 'column-name', 'column-type', 'column-option', 'index-name' ) as $rulesType )
        {
            if( !isset( $transformationRules[$rulesType] ) )
                $transformationRules[$rulesType] = array();
        }

        return $transformationRules;
    }
409240
private function getClassName(SchemaDescriptor $schema)
    {
        return sprintf(
            '%s%s%sV%s',
            StringUtils::toCamelFromSlug($schema->getId()->getVendor()),
            StringUtils::toCamelFromSlug($schema->getId()->getPackage()),
            StringUtils::toCamelFromSlug($schema->getId()->getMessage()),
            preg_replace('/-/', '', $schema->getId()->getVersion())
        );
    }
339077
public function diffChangeLogFromSchemaDiff(SchemaDiff $schemaDiff, $output = null)
    {
        $output = $this->sanitizeOutputParameter($output);

        $output->started($this->em);

        foreach ($schemaDiff->newNamespaces as $newNamespace) {
            $output->createSchema($newNamespace);
        }

        foreach ($schemaDiff->orphanedForeignKeys as $orphanedForeignKey) {
            $output->dropForeignKey($orphanedForeignKey, $orphanedForeignKey->getLocalTable());
        }

        foreach ($schemaDiff->changedSequences as $sequence) {
            $output->alterSequence($sequence);
        }

        foreach ($schemaDiff->removedSequences as $sequence) {
            $output->dropSequence($sequence);
        }

        foreach ($schemaDiff->newSequences as $sequence) {
            $output->createSequence($sequence);
        }

        foreach ($schemaDiff->newTables as $table) {
            $output->createTable($table);
            
            foreach ($table->getForeignKeys() as $foreignKey) {
                $output->createForeignKey($foreignKey, $table);
            }
        }

        foreach ($schemaDiff->removedTables as $table) {
            $output->dropTable($table);
        }

        foreach ($schemaDiff->changedTables as $tableDiff) {
            $output->alterTable($tableDiff);
        }

        $output->terminated();

        return $output->getResult();
    }
92175
function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
		parent::nusoap_base();
		$this->debug('nusoap_xmlschema class instantiated, inside constructor');
		// files
		$this->schema = $schema;
		$this->xml = $xml;

		// namespaces
		$this->enclosingNamespaces = $namespaces;
		$this->namespaces = array_merge($this->namespaces, $namespaces);

		// parse schema file
		if($schema != ''){
			$this->debug('initial schema file: '.$schema);
			$this->parseFile($schema, 'schema');
		}

		// parse xml file
		if($xml != ''){
			$this->debug('initial xml file: '.$xml);
			$this->parseFile($xml, 'xml');
		}

	}
111730
public function schemaToFqClassName(SchemaDescriptor $schema, $withMajor = false)
    {
        $id = $schema->getId();
        $vendor = StringUtils::toCamelFromSlug($id->getVendor());
        $package = StringUtils::toCamelFromSlug(str_replace('.', '-', $id->getPackage()));
        return "{$vendor}{$package}{$this->schemaToClassName($schema, $withMajor)}";
    }
508161
protected function isProtobufExtension(FieldDescriptorProto $fieldDescriptor)
    {
        if ( ! $fieldDescriptor->hasExtendee()) {
            return false;
        }

        $extendee = trim($fieldDescriptor->getExtendee(), '.');
        $package  = 'google.protobuf';
        $length   = strlen($package);

        return (substr($extendee, 0, $length) === $package);
    }
336291
private function db_read_schema($schemafile)
    {
        $lines       = file($schemafile);
        $table_block = false;
        $schema      = array();
        $keywords    = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');

        foreach ($lines as $line) {
            if (preg_match('/^\s*create table ([\S]+)/i', $line, $m)) {
                $table_name = explode('.', $m[1]);
                $table_name = end($table_name);
                $table_name = preg_replace('/[`"\[\]]/', '', $table_name);
            }
            else if ($table_name && ($line = trim($line))) {
                if ($line == 'GO' || $line[0] == ')' || $line[strlen($line)-1] == ';') {
                    $table_name = null;
                }
                else {
                    $items = explode(' ', $line);
                    $col   = $items[0];
                    $col   = preg_replace('/[`"\[\]]/', '', $col);

                    if (!in_array(strtoupper($col), $keywords)) {
                        $type = strtolower($items[1]);
                        $type = preg_replace('/[^a-zA-Z0-9()]/', '', $type);

                        $schema[$table_name][$col] = $type;
                    }
                }
            }
        }

        return $schema;
    }
634065
private static function _vlookupSort($a,$b) {
		$f = array_keys($a);
		$firstColumn = array_shift($f);
		if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
			return 0;
		}
		return (strtolower($a[$firstColumn]) < strtolower($b[$firstColumn])) ? -1 : 1;
	}
159894
protected function updateSchema(Schema $schema) {
		foreach($schema->getJoins() as $join) {
			$assoc = $join->getAssociation();
			$parent = $join->getParent();
			if (is_null($parent))
				$assoc->appendJoin($this, $this->alias, $join->getAlias(), true);
			else {
				$alias = $schema->getJoin($parent)->getAlias();
				$assoc->appendJoin($this, $alias, $join->getAlias(), true);
			}
		}
	}
838864
public function has(string $schema, string $typeName, string $id) : bool
    {
        return !!$this->connection->createQueryBuilder()
            ->select('id')
            ->from($this->tableName($schema, $typeName))
            ->where('id = :id')
            ->setParameter('id', $id)
            ->execute()
            ->fetchColumn();
    }
1035729
public function compareUsingBcMath(DecimalNumber $a, DecimalNumber $b)
    {
        return bccomp((string) $a, (string) $b, max($a->getExponent(), $b->getExponent()));
    }
973869
public function has(string $schema, string $typeName, string $id) : bool
    {
        if (!$this->typeExists($schema, $typeName)) {
            return false;
        }

        return array_key_exists($id, $this->storage[$schema][$typeName]);
    }
1062850
public function coprime($a, $b)
    {
        $small = 0;
        $diff  = 0;
        while (bccomp($a, '0') > 0 && bccomp($b, '0') > 0) {
            if (bccomp($a, $b) == -1) {
                $small = $a;
                $diff  = bcmod($b, $a);
            }
            if (bccomp($a, $b) == 1) {
                $small = $b;
                $diff = bcmod($a, $b);
            }
            if (bccomp($a, $b) == 0) {
                $small = $a;
                $diff  = bcmod($b, $a);
            }
            $a = $small;
            $b = $diff;
        }
        if (bccomp($a, '1') == 0) {
            return true;
        }

        return false;
    }
968591
public static function intersects(array $a, array $b): bool
    {
        $a = (array)$a;
        $b = (array)$b;

        return count(self::intersection($a, $b)) > 0;
    }
1181089
private function matchBinded(string $target, SchemaInterface $schema): bool
    {
        if ($schema->getRole() == $target) {
            return true;
        }

        if (interface_exists($target) && is_a($schema->getClass(), $target, true)) {
            //Match by interface
            return true;
        }

        return false;
    }
423160
public function setSchemaDescription($schemaDescription, $locale = null)
    {
        $this->translate($locale, false)->setSchemaDescription($schemaDescription);
        $this->mergeNewTranslations();

        return $this;
    }