Resolves token namespace.

@param RequestStack $requestStack
@return string
9257
private function resolveNamespace(RequestStack $requestStack = null)
    {
        if ($requestStack !== null && ($request = $requestStack->getMasterRequest())) {
            return $request->isSecure() ? 'https-' : '';
        }

        return !empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']) ? 'https-' : '';
    }
45313
public function resolveNamespaceAlias($alias)
	{
		foreach ($this->namespaces as $namespace)
		{
			list($from, $to) = $namespace;

			if ($empty = empty($to) or strpos($alias, $to) === 0)
			{
				if ( ! $empty)
				{
					$alias = substr($alias, strlen($to) + 1);
				}

				$class = $from.'\\'.$alias;
				$this->resolving[] = $class;

				if ($this->objectExists($class, true))
				{
					array_pop($this->resolving);

					return $class;
				}
			}
		}

		return false;
	}
229022
public function toNamespacedString($namespace, array $aliased_classes, $this_class, $use_phpdoc_format)
    {
        if ($use_phpdoc_format) {
            return 'object';
        }

        return 'object{' .
                implode(
                    ', ',
                    array_map(
                        /**
                         * @param  string|int $name
                         * @param  Union  $type
                         *
                         * @return string
                         */
                        function (
                            $name,
                            Union $type
                        ) use (
                            $namespace,
                            $aliased_classes,
                            $this_class,
                            $use_phpdoc_format
                        ) {
                            return $name . ($type->possibly_undefined ? '?' : '') . ':' . $type->toNamespacedString(
                                $namespace,
                                $aliased_classes,
                                $this_class,
                                $use_phpdoc_format
                            );
                        },
                        array_keys($this->properties),
                        $this->properties
                    )
                ) .
                '}';
    }
919227
public static function tokenName($tokenType)
    {
        switch ($tokenType) {
            case self::T_UNDEFINED:
                return 'T_UNDEFINED';
            case self::T_OPEN_PARENS:
                return 'T_OPEN_PARENS';
            case self::T_CLOSE_PARENS:
                return 'T_CLOSE_PARENS';
            case self::T_OR:
                return 'T_OR';
            case self::T_AND:
                return 'T_AND';
            case self::T_QUERY:
                return 'T_QUERY';
            case self::T_SPACE:
                return 'T_SPACE';
            case self::T_TRUE:
                return 'T_TRUE';
            case self::T_FALSE:
                return 'T_FALSE';
            default:
                return '"' . (string) $tokenType . '"';
        }
    }
594496
public function getTokenName()
    {
        $session = \PHPSession::singleton();

        if ($session->hasAttribute(TokenStore::TOKEN_NAME)) {
            $name = $session->getAttribute(TokenStore::TOKEN_NAME);
        } else {
            $name = 'tao_' . substr(md5(microtime()), rand(0, 25), 7);
            $session->setAttribute(TokenStore::TOKEN_NAME, $name);
        }

        return $name;
    }
1287089
public function getNamespace(): string
    {
        // Check cache.
        if (null === $this->namespace) {
            $tokens = $this->getTokenStream();
            // Find namespace token
            try {
                $loc = $tokens->scan(0, [T_NAMESPACE]);
            } catch (\OutOfBoundsException $e) {
                return $this->namespace = '';
            }

            // Get the next token (start with namespace)
            if ($loc !== null) {
                $loc = $tokens->next($loc);
            }

            // If the start of the namespace is found,
            // parse it, otherwise save empty namespace.
            $this->namespace = '';
            if ($loc !== null) {
                $this->namespace = $this->parseNamespace($loc);
            }
        }

        return $this->namespace;
    }
620374
def _parseAtNamespace(self, src):
        

        src = self._parseSCDOCDC(src)
        while isAtRuleIdent(src, 'namespace'):
            ctxsrc = src
            src = stripAtRuleIdent(src)

            namespace, src = self._getStringOrURI(src)
            if namespace is None:
                nsPrefix, src = self._getIdent(src)
                if nsPrefix is None:
                    raise self.ParseError('@namespace expected an identifier or a URI', src, ctxsrc)
                namespace, src = self._getStringOrURI(src.lstrip())
                if namespace is None:
                    raise self.ParseError('@namespace expected a URI', src, ctxsrc)
            else:
                nsPrefix = None

            src = src.lstrip()
            if src[:1] != ';':
                raise self.ParseError('@namespace expected a terminating \';\'', src, ctxsrc)
            src = src[1:].lstrip()

            self.cssBuilder.atNamespace(nsPrefix, namespace)

            src = self._parseSCDOCDC(src)
        return src
780617
public function toNamespacedString($namespace, array $aliased_classes, $this_class, $use_phpdoc_format)
    {
        if ($this->as === 'object') {
            return 'class-string';
        }

        if ($namespace && stripos($this->as, $namespace . '\\') === 0) {
            return 'class-string<' . preg_replace(
                '/^' . preg_quote($namespace . '\\') . '/i',
                '',
                $this->as
            ) . '>';
        }

        if (!$namespace && stripos($this->as, '\\') === false) {
            return 'class-string<' . $this->as . '>';
        }

        if (isset($aliased_classes[strtolower($this->as)])) {
            return 'class-string<' . $aliased_classes[strtolower($this->as)] . '>';
        }

        return 'class-string<\\' . $this->as . '>';
    }
999495
private function _namespace() {
    $node = new NamespaceNode();
    $this->matchDocComment($node);
    $this->mustMatch(T_NAMESPACE, $node);
    if ($this->currentType === T_STRING) {
      $name = $this->namespaceName();
      $node->addChild($name, 'name');
    }
    $this->matchHidden($node);
    $body = new StatementBlockNode();
    if ($this->tryMatch('{', $body)) {
      $this->topStatementList($body, '}');
      $this->mustMatch('}', $body);
      $node->addChild($body, 'body');
    }
    else {
      $this->endStatement($node);
      $this->matchHidden($node);
      $node->addChild($this->namespaceBlock(), 'body');
    }
    return $node;
  }
1072698
protected function getNamespace($key, array $tokens)
    {
        $namespace = null;
        $tokenCount = count($tokens);
        for ($i = $key; $i < $tokenCount; $i++) {
            if ($this->isPartOfNamespace($tokens[$i])) {
                $namespace .= $tokens[$i][1];
            } elseif ($tokens[$i] == ';') {
                return $namespace;
            }
        }
    }
177761
public function resolveEntityClassName($entityPostfix, array $namespacesIndex = [], $entityInterface)
    {
        $entityClassName = false;
        foreach ($namespacesIndex as $rootNamespace) {
            $currentEntityClassName = $rootNamespace . $entityPostfix;
            if (class_exists($currentEntityClassName)) {
                $r = new ReflectionClass($currentEntityClassName);
                if ($r->implementsInterface($entityInterface)) {
                    $entityClassName = $currentEntityClassName;
                    break;
                }
            }
        }

        return $entityClassName;
    }
947065
private function resolveNamespace($parameters, $handler, $matches)
    {
        if (isset($handler['module'])) {
            $moduleName = $handler['module'];
            if ($this->isPlaceholder($moduleName)) {
                foreach ($handler as $target => $placeholder) {
                    foreach ($parameters as $key => $parameterName) {
                        if ($parameterName[0][0] == $placeholder) {
                            if ($target == 'module') {
                                $moduleName = $matches[$key];
                            }
                        }
                    }
                }
            }

            return implode(
                '\\',
                [
                    $this->baseNamespace,
                    $this->moduleName,
                    $moduleName,
                    $this->controllerName
                ]
            );
        }

        return $this->baseNamespace.'\\'.$this->controllerName;
    }
148361
protected function getRequestNamespacePath($request)
    {
        if (!$request instanceof Request) {
            $parentPath = $this->getRequestNamespacePath($request->getParentRequest());
            return $parentPath . ($parentPath !== '' && $request->getArgumentNamespace() !== '' ? '.' : '') . $request->getArgumentNamespace();
        }
        return '';
    }
712975
private function parseNamespace($tokens)
    {
        $namespace = null;
        $tokenCount = count($tokens);
        for ($offset=0; $offset < $tokenCount; $offset++) {
            if (!is_array($tokens[$offset])) {
                continue;
            }

            if (T_NAMESPACE === $tokens[$offset][0]) {
                $offset++; // the next token is a whitespace

                return $this->parseNamespaceString($tokens, $offset);
            }
        }

        return $namespace;
    }
818234
public static function tokenHasExtraWhiteSpaces($token)
    {
        return \strpos($token[Tokenizer::TOKEN_VALUE], ' ') !== false
        || \strpos($token[Tokenizer::TOKEN_VALUE], "\n") !== false
        || \strpos($token[Tokenizer::TOKEN_VALUE], "\t") !== false;
    }
790457
protected function lexFragmentName(?Token $token = null): NameNode
    {
        if (null === $token) {
            $token = $this->lexer->getToken();
        }

        if (KeywordEnum::ON === $token->getValue()) {
            throw $this->unexpected();
        }

        return $this->lexName();
    }
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}