class TokensList implements ArrayAccess (View source)

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 = [], int $count = -1)

No description

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

Builds an array of tokens by merging their raw value.

add(Token $token)

Adds a new token.

Token|null
getNext()

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

Token|null
getNextOfType(int $type)

Gets the next token.

Token|null
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

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

No description

Parameters

array $tokens

the initial array of tokens

int $count

the count of tokens in the initial array

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

add(Token $token)

Adds a new token.

Parameters

Token $token

token to be added in list

Token|null getNext()

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

Return Value

Token|null

Token|null getNextOfType(int $type)

Gets the next token.

Parameters

int $type

the type

Return Value

Token|null

Token|null 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|null

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

Token offsetGet(int $offset)

Gets a value from the container.

Parameters

int $offset

the offset to be returned

Return Value

Token

bool offsetExists(int $offset)

Checks if an offset was previously set.

Parameters

int $offset

the offset to be checked

Return Value

bool

offsetUnset(int $offset)

Unsets the value of an offset.

Parameters

int $offset

the offset to be unset