解析短选项
@param string $token 当前的指令.
506330
private function parseShortOption($token) {
        $name = substr($token, 1);

        if (strlen($name) > 1) {
            if ($this->definition->hasShortcut($name[0])
                && $this->definition->getOptionForShortcut($name[0])->acceptValue()
            ) {
                $this->addShortOption($name[0], substr($name, 1));
            }
            else {
                $this->parseShortOptionSet($name);
            }
        }
        else {
            $this->addShortOption($name, null);
        }
    }
1234792
private function _checkProhibitedKeywords($token) {
		if ($this->_isActive('checkProhibitedKeywords')) {
			foreach ($this->_prohibitedKeywords as $keyword) {
				if (strpos($token->text, $keyword) !== FALSE) {
					$msg = $this->_getMessage('PROHIBITED_KEYWORD', $token->text);
					$this->_writeError('checkProhibitedKeywords', $msg);
				}
			}
		}
	}
656213
protected function handleEach(array $token)
    {

        $node = $this->createNode('each', $token);
        $node->subject = $token['subject'];
        $node->itemName = $token['itemName'];
        $node->keyName = isset($token['keyName']) ? $token['keyName'] : null;

        $this->current = $node;
    }
1198479
private function _checkProhibitedTokens($token) {
		if ($this->_isActive('checkProhibitedTokens')) {
			if (in_array($token->getName(), $this->_prohibitedTokens)) {
				$msg = $this->_getMessage("PROHIBITED_TOKEN", $token->getName());
				$this->_writeError('checkProhibitedTokens', $msg);
			}
		}
	}
1052728
public function setToken($token)
    {
        $this->tokenKey = $token->key;
        $this->tokenSecret = $token->secret;

        return $this;
    }
1368090
public function setOAuth2Token ($token)
    {
        if (!StringUtilities::isNullOrEmpty($token))
        {
            $this->oAuth2Token = $token;
            $this->headers[]   = "Authorization: OAuth " . $this->oAuth2Token;
        }
    }
860808
private function _processToken($token) {
		// Debug
		if ($this->debug) {
			echo $this->statementStack->getStackDump() . PHP_EOL;
			echo "Level " . $this->statementStack->count() . " - " . $token->toString() . PHP_EOL;
		}

		// Check if the token is in the list of prohibited tokens
		$this->_checkProhibitedTokens($token);

		// Check if the token text is in the list of prohibited keywords
		$this->_checkProhibitedKeywords($token);

		// Check if the token text correspond to a prohibited regular expression
		$this->_checkProhibitedKeywordsRegex($token);

		// Specific tokens checks
		switch ($token->id) {

			case T_COMMENT:
			case T_ML_COMMENT:
			case T_DOC_COMMENT:
				$this->_processComment($token);
				break;

			case T_OPEN_TAG:
				$this->_processOpenTag($token);
				break;

			case T_CLOSE_TAG:
				$this->_processCloseTag($token);
				break;

			case T_DO:
			case T_WHILE:
			case T_IF:
			case T_ELSEIF:
			case T_FOR:
			case T_FOREACH:
				$this->_processControlStatement($token);
				$this->_cyclomaticComplexity ++;
				$this->_npathComplexity ++;
				break;

			case T_SWITCH:
				$this->_processSwitchStart();
				$this->_processControlStatement($token);
				$this->_cyclomaticComplexity ++;
				$this->_npathComplexity ++;
				break;

			case T_ELSE:

				// We don't increment the cyclomatic complexity for the last else
				$this->_processControlStatement($token);
				$this->_npathComplexity ++;
				break;

			case T_CASE:
				$this->_processSwitchCase();
				$this->_cyclomaticComplexity ++;
				$this->_npathComplexity ++;
				break;

			case T_DEFAULT:
				$this->_processSwitchDefault();
				$this->_npathComplexity ++;
				break;

			case T_BREAK:
				$this->_processSwitchBreak();
				break;

			case T_TRY:
				$this->_processControlStatement($token);
				$this->_npathComplexity ++;
				break;

			case T_CATCH:
				$this->_processCatch();
				$this->_processControlStatement($token);
				$this->_npathComplexity ++;
				break;

			case T_FINALLY:
				$this->_processFinally();
				$this->_processControlStatement($token);
				$this->_npathComplexity ++;
				break;

			case T_WHITESPACE:
			case T_TAB:

				if ($this->_isLineStart) {
					// If the whitespace is at the start of the line, we check for indentation
					$this->_checkIndentation($token);
				}
				break;

			case T_INLINE_HTML:
				break;

			// beginning of a function definition
			// check also for existence of docblock
			case T_FUNCTION:
				$this->_processFunctionStatement();
				break;

			// beginning of a class
			// check also for the existence of a docblock
			case T_CLASS:
				$this->_processClassStatement();
				break;

			// beginning of an interface
			// check also for the existence of a docblock
			case T_INTERFACE:
				$this->_processInterfaceStatement();
				break;

			// Namespace declaration
			case T_NAMESPACE:
				$this->_processNamespace();
				break;

			// operators, generally, need to be surrounded by whitespace
			case T_PLUS_EQUAL:
			case T_MINUS_EQUAL:
			case T_MUL_EQUAL:
			case T_DIV_EQUAL:
			case T_CONCAT_EQUAL:
			case T_MOD_EQUAL:
			case T_AND_EQUAL:
			case T_OR_EQUAL:
			case T_XOR_EQUAL:
			case T_SL_EQUAL:
			case T_SR_EQUAL:
			case T_BOOLEAN_OR:
			case T_BOOLEAN_AND:
			case T_IS_IDENTICAL:
			case T_IS_NOT_IDENTICAL:
			case T_IS_SMALLER_OR_EQUAL:
			case T_IS_GREATER_OR_EQUAL:
			case T_IS_GREATER:
			case T_IS_SMALLER:
			case T_PLUS:
			case T_MULTIPLY:
			case T_DIVIDE:
			case T_QUESTION_MARK:
			case T_COLON:
			case T_MODULO:
			case T_CONCAT:
				$this->_checkWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token->text);
				break;

			case T_IS_EQUAL:
			case T_IS_NOT_EQUAL:
				$this->_checkStrictCompare($token->text);
				$this->_checkWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token->text);
				break;

			case T_LOGICAL_AND:
				if ($this->_isActive('useBooleanOperators')) {
					$this->_writeError('useBooleanOperators', $this->_getMessage("USE_BOOLEAN_OPERATORS_AND"));
				}
				$this->_checkWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token->text);
				break;

			case T_LOGICAL_OR:
				if ($this->_isActive('useBooleanOperators')) {
					$this->_writeError('useBooleanOperators', $this->_getMessage("USE_BOOLEAN_OPERATORS_OR"));
				}
				$this->_checkWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token->text);
				break;

			// ASSUMPTION:
			// that T_STRING followed by "(" is a function call
			// Actually, I am not sure how good an assumption this is.
			case T_STRING:

				// If the word "define" have been used right before the string
				if ($this->_constantDef === true) {
					$this->_checkConstantNaming($token->text);
				}

				// Check whether this is a function call (and if "define", set the flag)
				$this->_processFunctionCall($token->text);

				break;

			case T_CONST:

				// Skip until T_STRING representing the constant name
				while (!$this->tokenizer->checkCurrentToken(T_STRING)) {
					$this->tokenizer->getNextToken();
				}
				$this->_constantDef = true;
				$token = $this->tokenizer->getCurrentToken();
				$this->_checkConstantNaming($token->text);
				break;

			case T_CONSTANT_ENCAPSED_STRING:

				// If the word "define" have been used right before the constant encapsed string
				if ($this->_constantDef === true) {
					$this->_checkConstantNaming($token->text);
				}
				break;

			case T_ENCAPSED_AND_WHITESPACE:

				// Constant part of string with variables
				$this->_checkEncapsedVariablesInsideString();
				break;

			case T_CURLY_OPEN: // for protected variables within strings "{$var}"
				$stackitem = new StatementItem();
				$stackitem->line = $token->line;
				$stackitem->type = 'curly_open';
				$stackitem->name = 'curly_open';
				$this->statementStack->push($stackitem);
				break;

			case T_DOLLAR_OPEN_CURLY_BRACES: // for extended format "${var}"
				$stackitem = new StatementItem();
				$stackitem->line = $token->line;
				$stackitem->type = 'dollar_curly_open';
				$stackitem->name = 'dollar_curly_open';
				$this->statementStack->push($stackitem);
				break;

			case T_NEW_LINE:
				$this->_countLinesOfCode();
				// Case of a control statement without parenthesis, it closes at the end of the line
				if ($this->_inControlStatement && $this->_csLeftParenthesis === 0) {
					$this->_inControlStatement = false;
				}
				// Test the length of the line, only if it's not html.
				if ($this->_isActive('lineLength')) {
					$this->_checkLargeLine();
				}
				break;

			case T_RETURN:
				$this->_processReturn();
				break;

			case T_THROW:
				$this->_processThrow();
				break;

			case T_INC:
			case T_DEC:
				$this->_checkUnaryOperator();
				break;

			case T_DOUBLE_ARROW:
				$this->_checkWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token);
				break;

			case T_OBJECT_OPERATOR:
				$this->_checkNoWhiteSpaceBefore($token->text);
				$this->_checkNoWhiteSpaceAfter($token);
				break;

			case T_START_HEREDOC:
				$this->_processStartHeredoc();
				break;

			case T_END_HEREDOC:
				$this->_processEndHeredoc();
				break;

			case T_VARIABLE:
				$this->_processVariable($token->text);
				break;

			case T_GOTO:
				$this->_checkGoTo();
				break;

			case T_CONTINUE:
				$this->_checkContinue();
				break;

			case T_EXIT: // exit() of die()
				$this->_checkAliases($token->text);
				break;

			case T_BRACES_OPEN: // {
				if (!$this->_checkComplexVariable2($token)) {
					$this->_processBracesOpen($token);
				}
				break;
			case T_BRACES_CLOSE: // }
				$this->_processBracesClose($token);
				break;

			case T_SEMICOLON: // ;
				$this->_processSemiColon($token);
				break;

			case T_MINUS:
				$this->_processMinus($token);
				break;

			case T_EQUAL:
				$this->_checkInnerAssignment();
				$this->_checkWhiteSpaceBefore($token->text);
				// whitespace after (exept for Assign By Reference)
				if (!$this->tokenizer->checkNextToken(T_AMPERSAND)) {
					$this->_checkWhiteSpaceAfter($token->text);
				}
				break;

			case T_COMMA:
				$this->_checkNoWhiteSpaceBefore($token->text);
				$this->_checkWhiteSpaceAfter($token->text);
				break;

			case T_EXCLAMATION_MARK:
				$this->_checkNoWhiteSpaceAfter($token);
				break;

			case T_PARENTHESIS_OPEN:
				$this->_processParenthesisOpen($token);
				$this->_checkNoWhiteSpaceAfter($token);
				break;

			case T_PARENTHESIS_CLOSE:
				$this->_processParenthesisClose($token);
				$this->_checkNoWhiteSpaceBefore($token->text);
				break;

			case T_AMPERSAND:

				// One of the function parameter is passed by reference
				if ($this->_isActive('avoidPassingReferences')) {
					if ($this->_inFunctionStatement) {
						$this->_writeError('avoidPassingReferences', $this->_getMessage("PASSING_REFERENCE"));
					}
				}
				break;
			case T_SQUARE_BRACKET_OPEN:
				$this->_processSquareBracketOpen($token);
				break;
			case T_SQUARE_BRACKET_CLOSE:
				$this->_processSquareBracketClose($token);
				break;
			case T_QUOTE:
				$this->_checkPreferQuotes($token);
				$this->_inString = !$this->_inString;
				break;
			case T_DOLLAR:
				if (!$this->_checkComplexVariable($token)) {
					$this->_checkVariableVariable($token);
				}
				break;
			case T_ARRAY:
				$this->_processArray($token);
				break;
			default:
				break;
		}

		// If the last token is a NEW_LINE, the next token will be at the start of the line
		$this->_isLineStart = ($token->id === T_NEW_LINE);
	}
833601
public function setAccessToken($token)
    {
        if (!\is_array($token)) {
            throw new AuthException('Token is not a valid json string.');
        }

        if (isset($token['data']['access_token'])) {
            $token = $token['data'];
        }

        if (!isset($token['access_token'])) {
            throw new AuthException('Access token could not be retrieved from the decoded json response.');
        }

        $this->token = $token;

        $this->sign();
    }
606712
protected function handleCase(array $token)
    {

        $node = $this->createNode('case', $token);
        $node->subject = $token['subject'];
        $this->current = $node;
    }
4770
static public function resetCaptcha($token=null)
    {
        if (!$token) {
            $token = isset($_POST['_form_token']) ? $_POST['_form_token'] : null;
        }
        
        return Captcha::instance()->reset($token);
    }
534849
public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
255349
public function addToken($token)
    {
        if (!in_array($token, $this->tokens)) {
            $this->tokens[] = $token;
        }

        return $this;
    }
995022
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $count = null;
        $vars = new ArrayExpression([], $lineno);
        $domain = null;
        $locale = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            if ($stream->test('count')) {
                // {% trans count 5 %}
                $stream->next();
                $count = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('with')) {
                // {% trans with vars %}
                $stream->next();
                $vars = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('from')) {
                // {% trans from "messages" %}
                $stream->next();
                $domain = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('into')) {
                // {% trans into "fr" %}
                $stream->next();
                $locale = $this->parser->getExpressionParser()->parseExpression();
            } elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
                throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
            }
        }

        // {% trans %}message{% endtrans %}
        $stream->expect(Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse([$this, 'decideTransFork'], true);

        if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
            throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag());
    }
510322
private function _processSquareBracketOpen($token) {

		// If the [ is preceded by = we are in a array declaration
		if ($this->tokenizer->checkPreviousValidToken(T_EQUAL)) {

			$stackitem = new StatementItem();
			$stackitem->line = $token->line;
			$stackitem->type = 'ARRAY';
			$stackitem->name = 'square_bracket_open';

			$this->statementStack->push($stackitem);
		}
	}
1001788
public function handlesToken($token)
    {
        return (
            isset($this->tokensHandled)
            && is_array($this->tokensHandled)
            && in_array($token, $this->tokensHandled)
        );
    }
235082
private function parseLongOption($token) {
        $name = substr($token, 2);

        if (false !== $pos = strpos($name, '=')) {
            $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1));
        }
        else {
            $this->addLongOption($name, null);
        }
    }
1233971
public function setCookieToken($token)
    {
        $this->cookieToken = $token; // Remember this for this request.
        $encrypted = Encryption::encrypt($token, $this->config->getSecretKey()); // Encrypt token.

        // Set cookie on client.
        setcookie($this->config->getCookieName(),
            $encrypted,
            time() + $this->config->getTokenTtl(),
            '/',
            '',
            $this->config->getCookieSslOnly(),
            $this->config->getCookieHttpOnly()); // Store in cookie.
    }