TokensList
class TokensList implements ArrayAccess (View source)
Defines an array of tokens and utility functions to iterate through it.
A structure representing a list of tokens.
Properties
Token[] | $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
Token|null
getNextOfType(int $type)
Gets the next token.
Token|null
getNextOfTypeAndValue(int $type, string $value)
Gets the next token.
bool
offsetExists(int $offset)
Checks if an offset was previously set.
void
offsetUnset(int $offset)
Unsets the value of an offset.
Details
__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.
void
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.
void
offsetSet(int|null $offset, Token $value)
Sets an value inside the container.
Token|null
offsetGet(int $offset)
Gets a value from the container.
bool
offsetExists(int $offset)
Checks if an offset was previously set.
void
offsetUnset(int $offset)
Unsets the value of an offset.