Gets the next token.

@param int    $type  the type of the token
@param string $value the value of the token

@return Token
764999
public function getNextOfTypeAndValue($type, $value)
    {
        for (; $this->idx < $this->count; ++$this->idx) {
            if (($this->tokens[$this->idx]->type === $type)
                && ($this->tokens[$this->idx]->value === $value)
            ) {
                return $this->tokens[$this->idx++];
            }
        }

        return null;
    }
787295
protected function convert ($type, $value)
		{
			switch ($type)
			{
				case 'string':
					return (string) $value;

				case 'number':
					return is_float($value)
						? (float) $value
						: (int) $value;

				case 'boolean':
					return $value === true || $value === 'true' || $value === '1' || $value === 'on';

				default:
					if (is_float($value))
					{
						return $this->convert('number', $value);
					}
					if (is_numeric($value))
					{
						return strpos($value, '.') !== FALSE
							? (float) $value
							: (int) $value;
					}
					if ($value === 'true' || $value === 'false')
					{
						return $value === 'true';
					}
					if ($value === '')
					{
						return null;
					}
			}
			return $value;
		}
74910
public static function check_token($value = null)
	{
		$value = $value ?: \Input::param(static::$csrf_token_key, \Input::json(static::$csrf_token_key, 'fail'));

		// always reset token once it's been checked and still the same
		if (static::fetch_token() == static::$csrf_old_token and ! empty($value))
		{
			static::set_token(true);
		}

		return $value === static::$csrf_old_token;
	}
98001
protected function setValue($value, string $type)
    {
        $this->value = $type !== self::TYPE_CALL
            ? $this->validateValue($value)
            : array_map(function ($value) {
                return $this->validateValue($value);
            }, $value);
    }
1126555
protected function next_token(){
		$this->tok = next( $this->input );
		$this->t = self::token_to_symbol( $this->tok );
		return $this->tok;
	}
1264204
protected function getValueForCondition($value, $type)
    {
        // check if date and not a relative value like -1 week
        if (DataTypes::DATETIME_TYPE === $type && !preg_match('/[A-Za-z]{3,}/', $value)) {
            return (new \DateTime($value))->format(\DateTime::ISO8601);
        }

        return $value;
    }
608080
public static function getType( $value )
    {
        $type = gettype($value);
        switch( $type ){
        case 'string':
            return $type . '(' . strlen($value) . ')';
            break;
        case 'integer':
        case 'float':
        case 'boolean':
            return $type . '(' . $value . ')';
            break;
        case 'NULL':
        case 'unknown type':
            return $type;
            break;
        case 'array':
            return $type . '(' . count($value) . ')';
            break;
        case 'object':
            if ( $value instanceof \Countable ){
                return get_class( $value ) . '(' . count($value) . ')';
            }
            elseif ( $value instanceof HashableInterface ){
                return get_class( $value ) . '(hash=' . $value->hash() . ')';
            }
            return get_class( $value );
            break;
        }
        return '';
    }
412057
public function nextOfType($tokenName)
    {
        $i = $this->index+1;
        $len = count($this->tokens);
        while ($i < $len) {
            $tok = $this->tokens[$i][0];
            if ($tok === $tokenName) {
                return $i;
            }
            $i++;
        }
        return $len;
    }
283217
public function with_value( $value ) {
		if ( $this->value === $value ) {
			return $this;
		}

		$cloned_token        = clone $this;
		$cloned_token->value = $value;

		return $cloned_token;
	}
235364
private function backBlock($step, $type, $value = NULL)
    {
        if ($this->_pos < 0) {
            return $this->startBlock($type, 0, $value);
        }
        $last = $this->_blocks[$this->_pos][2];
        $this->_blocks[$this->_pos][2] = $last - $step;
        if ($this->_blocks[$this->_pos][1] <= $this->_blocks[$this->_pos][2]) {
            $this->_pos ++;
        }
        $this->_current = $type;
        $this->_blocks[$this->_pos] = array(
            $type,  $last - $step + 1,  $last,  $value
        );
        return $this;
    }
295492
protected function skip($type)
    {
        if ($match = ($this->token->getType() === $type)) {
            $this->advance();
        }

        return $match;
    }
1058163
protected function getValue(Token $token, $value = null)
    {
        $value = $value ?: $token->match['value'];
        $type  = $token->match['type'];

        switch (true) {
            case $type === 'int':
                return (int) $value;
            case $type === 'char' &&
                 preg_match('(^(?P<value>-?\\d+)%2F100$)', $value, $match):
                return $match['value'] / 100;
            case $type === 'char':
                return (string) urldecode($value);
            default:
                throw new \RuntimeException(
                    "Unknown value type $type in line {$token->line} at position {$token->position}."
                );
        }
    }
1003470
protected function _type_assignment_set( $type, $value )
	{
		switch ( $type ) 
		{
			case 'int':
			case 'timestamp':
				return (int) $value;
			break;

			case 'string':
				return (string) $value;
			break;

			case 'bool':
				return (bool) $value;
			break;

			// json datatype simply encode
			case 'json':
				return json_encode( $value );
			break;
		}

		return $value;
	}
1315536
private function type($value, $type) {
        
        switch (func_num_args()) {
            case 0 :
            case 1 :
                return false;
            case 2 :
                // 二个参数时, 才执行正常处理逻辑
                
                if (is_array($type)) {
                    foreach ( $type as $t ) {
                        if ($this -> type($value, $t)) {
                            return true;
                        }
                    }
                    return false;
                }
                
                $t = strtolower(gettype($value));
                $type = strtolower($type);
                
                if ($type == $t) {
                    return true;
                } else if ($type == 'mixed') {
                    return true;
                } else {
                    switch ($t) {
                        case "integer" :
                            if ($type == 'int') {
                                return true;
                            }
                        case "double" :
                            return $type == 'number';
                        case "boolean" :
                            return $type == 'bool';
                        case "user function" :
                            return $type == 'function';
                        case "string" :
                        case "array" :
                        case "object" :
                        case "resource" :
                        case "null" :
                        case "unknown type" :
                        default :
                            return false;
                    }
                }
                return false;
            default :
                // 多于两个参数,认为第二个及其后的统统为可能的值.
                $varList = func_get_args();
                $value = array_shift($varList);
                
                return $this -> type($value, $varList);
        }
    
    }
467107
protected function _type_assignment_get( $type, $value )
	{
		switch ( $type ) 
		{
			case 'int':
			case 'timestamp':
				return (int) $value;
			break;

			case 'string':
				return (string) $value;
			break;

			case 'bool':
				return (bool) $value;
			break;

			// json datatype try to decode return array on failure
			case 'json':
				if ( is_array( $value ) )
				{
					return $value;
				}
				if ( is_array( $value = json_decode( $value, true ) ) )
				{
					return $value;
				}
				return array();
			break;
		}

		return $value;
	}
193687
public function typeIs($value)
    {
        $this->add(new Criterium(self::CRITERIUM_TYPE_IS, (int) $value));

        return $this;
    }
111443
protected function escape($value, $type = \PDO::PARAM_STR)
    {
        return $this->getBuilder()->getConnection()->escape($value, $type);
    }