Handle namespace declaration.

@param int $tokenID
550231
private function registerNamespace(int $tokenID)
    {
        $namespace = '';
        $localID = $tokenID + 1;

        do {
            $token = $this->tokens[$localID++];
            if ($token[self::TOKEN_CODE] == '{') {
                break;
            }

            $namespace .= $token[self::TOKEN_CODE];
        } while (
            isset($this->tokens[$localID])
            && $this->tokens[$localID][self::TOKEN_CODE] != '{'
            && $this->tokens[$localID][self::TOKEN_CODE] != ';'
        );

        //Whitespaces
        $namespace = trim($namespace);

        $uses = [];
        if (isset($this->namespaces[$namespace])) {
            $uses = $this->namespaces[$namespace];
        }

        if ($this->tokens[$localID][self::TOKEN_CODE] == ';') {
            $endingID = count($this->tokens) - 1;
        } else {
            $endingID = $this->endingToken($tokenID);
        }

        $this->namespaces[$namespace] = [
            self::O_TOKEN => $tokenID,
            self::C_TOKEN => $endingID,
            self::N_USES  => $uses,
        ];
    }
933990
public function setTokenName(string $name)
    {
        if (empty($name)) {
            Throw new TokenException('Empty token name is not allowed.');
        }

        $this->name = $name;
    }
116876
public function setNamespace(string $namespace): void
	{
		$storage = $this->getStorage();
		if ($storage instanceof UserStorage) {
			$storage->setNamespace($namespace);
		}
		$this->initIdentity();
	}
1183968
protected function handleEntryState($content, $position, TokenList $tokenList) {
        $tokenList->addToken($this->name . self::OPEN, $position);
    }
269543
public function setToken($tokenId, CsrfToken $token) {
		
		if(!trim((string) $tokenId)) {
			throw new \InvalidArgumentException('Invalid token id.');
		}
		
		$this->sessionDataBag->set(
			$this->namespace . '/' . $tokenId,
			$token
		);
	}
392297
private function collectUsedNamespace(array $tokens, $stackPointer)
    {
        $namespace = '';
        $next      = 2;
        do
        {
            $type = $tokens[$stackPointer + $next]['type'];
            if ($type === 'T_STRING' || $type === 'T_NS_SEPARATOR')
            {
                $namespace .= $tokens[$stackPointer + $next]['content'];
            }
            $next++;
        } while ($tokens[$stackPointer]['line'] === $tokens[$stackPointer + $next]['line']);

        if ($namespace === '')
        {
            $type  = 'Use without namespace found.';
            $data  = [$tokens[$stackPointer]['content']];
            $error = 'Use without qualified namespace found.';
            $this->file->addWarning($error, $stackPointer, $type, $data);
        }
        else
        {
            $this->usePaths[] = trim($namespace);
        }
    }
1342507
public function isAccessTokenRevoked($tokenId)
    {
        /** @var \Concrete\Core\Entity\OAuth\AccessToken $token */
        $token = $this->find($tokenId);
        if (!$token) {
            // The token was manually removed.
            return true;
        }

        $now = new \DateTime('now');
        // If we have a token and it has expired...
        if ($token && $token->getExpiryDateTime() < $now) {
            return true;
        }

        return false;
    }
420455
public function getToken($tokenId) {

		if($this->storage->hasToken($tokenId)) {
			return $this->storage->getToken($tokenId);
		}

		$token = new CsrfToken(
			$tokenId,
			$this->generateValue((int) $this->tokenLength)
		);

		$this->storage->setToken($tokenId, $token);

		return $token;
	}
101868
def handle_namespace_default(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        """"""
        name = tokens[NAME]
        self.raise_for_missing_default(line, position, name)
        return tokens
1042574
protected function expectSingleSpaceAfter(File $phpcsFile, int $stackPtr, string $tokenName): void
    {
        $tokens = $phpcsFile->getTokens();

        $nextIndex = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
        if ($nextIndex === $stackPtr + 1) {
            $fix = $phpcsFile->addFixableError('Whitespace missing after ' . $tokenName, $stackPtr, 'MissingAfter');
            if ($fix) {
                $phpcsFile->fixer->addContent($stackPtr, ' ');
            }
            return;
        }

        if ($tokens[$stackPtr + 1]['content'] !== ' ') {
            $error = 'Whitespace invalid after ' . $tokenName . ', expected ` `, got `' . $tokens[$stackPtr + 1]['content'] . '`';
            $fix = $phpcsFile->addFixableError($error, $stackPtr, 'InvalidAfter');
            if ($fix) {
                for ($i = $nextIndex - 1; $i > $stackPtr + 1; $i--) {
                    $phpcsFile->fixer->replaceToken($i, '');
                }
                $phpcsFile->fixer->replaceToken($stackPtr + 1, ' ');
            }
        }
    }
190533
public function getNamespace($modelid)
    {
        $returnValue = null;
    
        if(count($this->namespaces) == 0){
        	$this->getAllNamespaces();	//load the namespaces attribute 
       	}
        
        //get modelId from modelUri
        if(is_string($modelid)){
        	$modelid = array_search($modelid, $this->namespaces);
        }
        
    	//get namespace from modelId
    	if(is_int($modelid)){
        	if(isset($this->namespaces[$modelid])){
        		$returnValue = new common_ext_Namespace($modelid, $this->namespaces[$modelid]);
        	}
        }

        return $returnValue;
    }
1038677
public function deleteToken(TokenUUID $tokenUUID)
    {
        $this->load();
        parent::deleteToken($tokenUUID);
        $this->save();
    }
1247465
public function destroy_token($tokenId) {
		try {
			$sql = "DELETE FROM ". $this->table ." WHERE auth_token_id=:tokenId";
			$deleteRes = $this->db->run_update($sql, array('tokenId'=>$tokenId));
		}
		catch(exception $e) {
			throw new exception(__METHOD__ .": failed to destroy token::: ". $e->getMessage());
		}
		
		return($deleteRes);
	}
249524
public static function closure($tokenId, array $tokens) {
		if ($tokens[$tokenId]['id'] !== T_FUNCTION) {
			throw new \Exception('Cannot call params on non function');
		}
		$total = count($tokens);
		for ($key = $tokenId; $key <= $total; $key++) {
			if ($tokens[$key]['id'] === T_STRING) {
				return false;
			} elseif (in_array($tokens[$key]['content'], array('(', '{', ':'))) {
				return true;
			}
		}
		return false;
	}
243028
private function _identifyTokens($tokenText, $tokenID) {
		// Split the data up by newlines
		// To correctly handle T_NEW_LINE inside comments and HTML
		$splitData = preg_split('#(\r\n|\n|\r)#', $tokenText, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
		foreach ($splitData as $data) {

			$tokenInfo = new TokenInfo();
			$tokenInfo->text = $data;
			$tokenInfo->position = $this->tokenNumber;
			$tokenInfo->line = $this->lineNumber;

			if ($data === "\r\n" || $data === "\n" || $data === "\r") {
				// This is a new line token
				$tokenInfo->id = T_NEW_LINE;
				$this->lineNumber ++;
			} else if ($data === "\t") {
				// This is a tab token
				$tokenInfo->id = T_TAB;
			} else {
				// Any other token
				$tokenInfo->id = $tokenID;
			}

			$this->tokenNumber ++;

			// Added detections
			if ($tokenInfo->id === T_UNKNOWN) {
				switch ($tokenInfo->text) {
					case ";":
						$tokenInfo->id = T_SEMICOLON;
						break;
					case "{":
						$tokenInfo->id = T_BRACES_OPEN;
						break;
					case "}":
						$tokenInfo->id = T_BRACES_CLOSE;
						break;
					case "(":
						$tokenInfo->id = T_PARENTHESIS_OPEN;
						break;
					case ")":
						$tokenInfo->id = T_PARENTHESIS_CLOSE;
						break;
					case ",":
						$tokenInfo->id = T_COMMA;
						break;
					case "=":
						$tokenInfo->id = T_EQUAL;
						break;
					case ".":
						$tokenInfo->id = T_CONCAT;
						break;
					case ":":
						$tokenInfo->id = T_COLON;
						break;
					case "-":
						$tokenInfo->id = T_MINUS;
						break;
					case "+":
						$tokenInfo->id = T_PLUS;
						break;
					case ">":
						$tokenInfo->id = T_IS_GREATER;
						break;
					case "<":
						$tokenInfo->id = T_IS_SMALLER;
						break;
					case "*":
						$tokenInfo->id = T_MULTIPLY;
						break;
					case "/":
						$tokenInfo->id = T_DIVIDE;
						break;
					case "?":
						$tokenInfo->id = T_QUESTION_MARK;
						break;
					case "%":
						$tokenInfo->id = T_MODULO;
						break;
					case "!":
						$tokenInfo->id = T_EXCLAMATION_MARK;
						break;
					case "&":
						$tokenInfo->id = T_AMPERSAND;
						break;
					case "[":
						$tokenInfo->id = T_SQUARE_BRACKET_OPEN;
						break;
					case "]":
						$tokenInfo->id = T_SQUARE_BRACKET_CLOSE;
						break;
					case "@":
						$tokenInfo->id = T_AROBAS;
						break;
					case '"':
						$tokenInfo->id = T_QUOTE;
						break;
					case '$':
						$tokenInfo->id = T_DOLLAR;
						break;
					default:
				}
			}

			$this->newTokens[] = $tokenInfo;
		}

		return $this->newTokens;
	}
444199
static function parseNamespaceDeclaration(array $tokens, &$i) {
    $id = ParserUtil::nextSubstantialExcl($tokens, $i);
    if (T_STRING !== $id) {
      return FALSE;
    }
    $fqcn = Ptk_Qcn::parse($tokens, $i);
    if (FALSE === $fqcn) {
      return FALSE;
    }
    return new AstNamespaceDeclaration($fqcn);
  }
549862
public function handleAddDir(): void
	{
		if ($this->presenter->isAjax() && $this->editable) {
			$files = $this->getFiles();
			$dirName = $this->generateName('newDir');
			mkdir($this->getFullPath($dirName));
			array_unshift($files, $this->rename($dirName));
			$this->template->files = $files;
			$this->redrawControl();
		} else {
			exit;
		}
	}