class Token (View source)

Defines a token along with a set of types and flags and utility functions.

An array of tokens will result after parsing the query.

A structure representing a lexeme that explicitly indicates its categorization for the purpose of parsing.

Constants

FLAG_NONE

FLAG_KEYWORD

FLAG_KEYWORD_RESERVED

FLAG_KEYWORD_COMPOSED

FLAG_KEYWORD_DATA_TYPE

FLAG_KEYWORD_KEY

FLAG_KEYWORD_FUNCTION

FLAG_NUMBER_HEX

FLAG_NUMBER_FLOAT

FLAG_NUMBER_APPROXIMATE

FLAG_NUMBER_NEGATIVE

FLAG_NUMBER_BINARY

FLAG_STRING_SINGLE_QUOTES

FLAG_STRING_DOUBLE_QUOTES

FLAG_COMMENT_BASH

FLAG_COMMENT_C

FLAG_COMMENT_SQL

FLAG_COMMENT_MYSQL_CMD

FLAG_OPERATOR_ARITHMETIC

FLAG_OPERATOR_LOGICAL

FLAG_OPERATOR_BITWISE

FLAG_OPERATOR_ASSIGNMENT

FLAG_OPERATOR_SQL

FLAG_SYMBOL_VARIABLE

FLAG_SYMBOL_BACKTICK

FLAG_SYMBOL_USER

FLAG_SYMBOL_SYSTEM

FLAG_SYMBOL_PARAMETER

Properties

string $token

The token it its raw string representation.

bool|float|int|string $value

The value this token contains (i.e. token after some evaluation).

string|null $keyword

The keyword value this token contains, always uppercase.

TokenType $type

The type of this token.

int $flags

The flags of this token.

int|null $position

The position in the initial string where this token started.

Methods

__construct(string $token, TokenType $type = TokenType::None, int $flags = self::FLAG_NONE)

No description

bool|float|int|string
extract()

Does a little processing to the token to extract a value.

string
getInlineToken()

Converts the token into an inline token by replacing tabs and new lines.

Details

__construct(string $token, TokenType $type = TokenType::None, int $flags = self::FLAG_NONE)

No description

Parameters

string $token

the value of the token

TokenType $type

the type of the token

int $flags

the flags of the token

bool|float|int|string extract()

Does a little processing to the token to extract a value.

If no processing can be done it will return the initial string.

Return Value

bool|float|int|string

string getInlineToken()

Converts the token into an inline token by replacing tabs and new lines.

Return Value

string