class TokensList implements ArrayAccess

A structure representing a list of tokens.

Properties

array $tokens The array of tokens.
int $count The count of tokens.
int $idx The index of the next token to be returned.

Methods

__construct(array $tokens = array(), int $count = -1)

Constructor.

static string
build(string|Token[]|TokensList $list)

Builds an array of tokens by merging their raw value.

add(Token $token)

Adds a new token.

getNext()

Gets the next token. Skips any irrelevant token (whitespaces and comments).

getNextOfType(int $type)

Gets the next token.

getNextOfTypeAndValue(int $type, string $value)

Gets the next token.

offsetSet(int $offset, Token $value)

Sets an value inside the container.

offsetGet(int $offset)

Gets a value from the container.

bool
offsetExists(int $offset)

Checks if an offset was previously set.

offsetUnset(int $offset)

Unsets the value of an offset.

Details

at line 45
__construct(array $tokens = array(), int $count = -1)

Constructor.

Parameters

array $tokens the initial array of tokens
int $count the count of tokens in the initial array

at line 62
static string build(string|Token[]|TokensList $list)

Builds an array of tokens by merging their raw value.

Parameters

string|Token[]|TokensList $list the tokens to be built

Return Value

string

at line 87
add(Token $token)

Adds a new token.

Parameters

Token $token token to be added in list

at line 98
Token getNext()

Gets the next token. Skips any irrelevant token (whitespaces and comments).

Return Value

Token

at line 118
Token getNextOfType(int $type)

Gets the next token.

Parameters

int $type the type

Return Value

Token

at line 137
Token getNextOfTypeAndValue(int $type, string $value)

Gets the next token.

Parameters

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

Return Value

Token

at line 156
offsetSet(int $offset, Token $value)

Sets an value inside the container.

Parameters

int $offset the offset to be set
Token $value the token to be saved

at line 172
Token offsetGet(int $offset)

Gets a value from the container.

Parameters

int $offset the offset to be returned

Return Value

Token

at line 184
bool offsetExists(int $offset)

Checks if an offset was previously set.

Parameters

int $offset the offset to be checked

Return Value

bool

at line 194
offsetUnset(int $offset)

Unsets the value of an offset.

Parameters

int $offset the offset to be unset