Lookup a fully qualified name in the given namespace considering imports.

@param string $localName
@param string $namespace
@param array<string, string> $import
@return string
338880
protected function lookup($localName, $namespace = '', array $import = [])
	{
		if($localName == '')
		{
			return $localName;
		}
		
		switch(strtolower($localName))
		{
			case 'bool':
			case 'int':
			case 'float':
			case 'string':
			case 'array':
			case 'callable':
				return strtolower($localName);
				break;
		}
		
		if($localName[0] == '\\')
		{
			return ltrim($localName, '\\');
		}
		
		if(false === (strpos($localName, '\\')))
		{
			$n = strtolower($localName);
			
			return isset($import[$n]) ? $import[$n] : ltrim($namespace . '\\' . $localName, '\\');
		}
		
		$parts = explode('\\', $localName, 2);
		$alias = strtolower($parts[0]);
		
		if(isset($import[$alias]))
		{
			return ltrim($import[$alias] . '\\' . $parts[1], '\\');
		}
		
		return ltrim($namespace . '\\' . $localName, '\\');
	}
644766
public function getFullyQualifiedClassName(string $className, string $defaultNamespace) : string
    {
        $rootNamespace = $this->getRootNamespace();

        // If the class name is already fully-qualified
        if (mb_strpos($className, $rootNamespace) === 0) {
            return $className;
        }

        return trim($defaultNamespace, '\\') . '\\' . $className;
    }
109402
public static function isStandardResourceOrExtLinkElement( $namespaceURI, $localName )
	{
		return 	$namespaceURI == self::$standardPrefixes[ STANDARD_PREFIX_LINK ] &&
				isset( self::$standardLinkElements[ $localName ] ) ||
				qnameNsLocalName( $namespaceURI, $localName )->equals( self::qnameNS( self::$ixRelationship ) );
	}
549459
private static function fqcn($name, array $imports): string
    {
        // Already FQCN
        if ($name[0] === '\\') {
            return $name;
        }

        // Aliased
        if (array_key_exists($name, $imports)) {
            return '\\' . $imports[$name];
        }

        // Check other imports
        if ($plain = self::getPlainImportIfExists($name, $imports)) {
            return '\\' . $plain;
        }

        // Not a complex type, or otherwise unknown.
        return '';
    }
1054538
public static function fromParts( $prefix, $localName, $ns, $resolver )
	{
		if ( is_null( $localName ) )
		{
			throw new \NullReferenceException("$localName");
		}

		if ( is_null( $ns ) )
		{
			throw new \NullReferenceException("$ns");
		}

		if ( is_null( $resolver ) )
		{
			throw new \NullReferenceException("$resolver");
		}

		if ($prefix != "" && $ns == "")
		{
			throw XPath2Exception::withErrorCodeAndParam("FOCA0002", Resources::FOCA0002, "{$prefix}:{$localName}" );
		}

		try
		{
			$pattern = NameValue::$ncName;

			// if ( ! preg_match( "/^[\p{L}_][\p{L}\p{N}_\-.]*$/u", $localName ) ) // NCName Start char + NCName
			if ( ! preg_match( "/^$pattern$/u", $localName ) ) // NCName Start char + NCName
			{
				throw new \InvalidArgumentException();
			}
			if ( empty( $prefix ) )
			{
				$prefix = $resolver->lookupPrefix( $ns );
				if ( ! $prefix ) $prefix = "";
			}
			$qname = new QNameValue();
			$qname->Prefix = $prefix;
			$qname->LocalName = $localName;
			$qname->NamespaceUri = $ns;
			return $qname;
		}
		catch( XmlException $ex )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $localName, "xs:QName" ) );
		}

	}
1123516
def has_regex_namespace_name(self, namespace: str, name: str) -> bool:
        """"""
        return self.has_regex_namespace(namespace) and self.namespace_to_pattern[namespace].match(name)
1166149
public function findQualifiedName($class, $type, $namespace = null)
    {
        // Check if we already resolved that name
        if (array_key_exists($class, $this->lookedUp)) {
            return $this->lookedUp[$type][$class];
        }

        $paths = $this->getLookups($type);
        $paths[] = '%s';

        // Create classes array
        $class = ucfirst($class);
        $classes = $namespace ? [ucfirst($namespace).'\\'.$class, $class] : [$class];

        // Search for first existing class
        $qualified = false;
        foreach ($classes as $class) {
            foreach ($paths as $path) {
                $path = sprintf($path, $class);
                if (class_exists($path)) {
                    $qualified = $path;
                    break 2;
                }
            }
        }

        return $this->lookedUp[$type][$class] = $qualified;
    }
533128
public function lookupPrefix( $namespace )
	{
		foreach ( $this->namespaces as $prefix => $value )
		{
			if ( strcasecmp( $namespace, $value ) === 0 ) return $prefix;
		}

		return false;
	}
50034
function (namespace, names){
    if (names){
      for (let i = 0, n = names.length; i < n; ++i){
        let typeName = names[i];
        if (namespace.names.hasOwnProperty(typeName)){
          this.names[typeName] = namespace.names[typeName];
        }
        else {
          throw new ReferenceError('import error: undefined type \'' + typeName + '\'');
        }
      }
    }
    else {
      // import *
      for (let typeName in namespace.names){
        if (namespace.names.hasOwnProperty(typeName)){
          this.names[typeName] = namespace.names[typeName];
        }
      }
    }
    return this;
  }
1219169
def qualified_name_import(cls):
    

    parts = qualified_name(cls).split('.')

    return "from {} import {}".format('.'.join(parts[:-1]), parts[-1])
804437
private function addToImportTable($alias, $functionOrConst, $namespaceNameParts, $contents, & $namespaceImportTable, & $functionImportTable, & $constImportTable):array
    {
        if ($alias !== null) {
            if ($functionOrConst === null) {
                // namespaces are case-insensitive
//                $alias = \strtolower($alias);
                $namespaceImportTable[$alias] = ResolvedName::buildName($namespaceNameParts, $contents);
                return array($namespaceImportTable, $functionImportTable, $constImportTable);
            } elseif ($functionOrConst->kind === TokenKind::FunctionKeyword) {
                // functions are case-insensitive
//                $alias = \strtolower($alias);
                $functionImportTable[$alias] = ResolvedName::buildName($namespaceNameParts, $contents);
                return array($namespaceImportTable, $functionImportTable, $constImportTable);
            } elseif ($functionOrConst->kind === TokenKind::ConstKeyword) {
                // constants are case-sensitive
                $constImportTable[$alias] = ResolvedName::buildName($namespaceNameParts, $contents);
                return array($namespaceImportTable, $functionImportTable, $constImportTable);
            }
            return array($namespaceImportTable, $functionImportTable, $constImportTable);
        }
        return array($namespaceImportTable, $functionImportTable, $constImportTable);
    }
459465
public function ns($nameSpace)
    {
        // If ! exist try to load a configuration file 
        if ( !isset($this->nameSpaces[$nameSpace]) ) {
            // short sanitize of nameSpace
            if (!filter_var( $nameSpace,FILTER_VALIDATE_REGEXP, 
                array('options'=>array('regexp' => '/^[\w]+$/')))) {
                    throw new InvalidArgumentException("Invalid configuration name.",400);
            }
            $this->nameSpaces[$nameSpace] = new ContextNameSpace($this->loadArrayFromIniFile($nameSpace));
        }
        
        return $this->nameSpaces[$nameSpace];
    }
603956
private function matchUseImports(Tokens $tokens, string $className): ?string
    {
        $namespaceUseAnalyses = $this->namespaceUsesAnalyzer->getDeclarationsFromTokens($tokens);

        foreach ($namespaceUseAnalyses as $namespaceUseAnalysis) {
            if ($className === $namespaceUseAnalysis->getShortName()) {
                return $namespaceUseAnalysis->getFullName();
            }
        }

        return null;
    }
337982
protected function loadNamespaced($locale, $group, $namespace)
    {
        if (isset($this->hints[$namespace])) {
            $lines = $this->loadPath($this->hints[$namespace], $locale, $group);

            return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);
        }

        return [];
    }
372732
private function getBundle(string $locale, string $namespace)
    {
        assert(empty($locale) === false && empty($namespace) === false);

        $bundles   = $this->getBundles();
        $hasBundle = isset($bundles[$locale][$namespace]) === true;
        $result    = $hasBundle === true ? $bundles[$locale][$namespace] : null;

        return $result;
    }
921364
def process_alias_import_namespace(namespace):
    
    if is_url(namespace.alias_source):
        alias_source = retrieve_file_from_url(namespace.alias_source)

        _validate_alias_file_content(alias_source, url=namespace.alias_source)
    else:
        namespace.alias_source = os.path.abspath(namespace.alias_source)
        _validate_alias_file_path(namespace.alias_source)
        _validate_alias_file_content(namespace.alias_source)
478058
def import_name(name):
    
    if isinstance(name, str):
        components = name.split('.')
        mod = __import__('.'.join(components[0:-1]), globals(), locals(), [components[-1]] )
        return getattr(mod, components[-1])
    else:
        return name