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
int | $count | The count of tokens. |
|
int | $idx | The index of the next token to be returned. |
Methods
No description
Builds an array of tokens by merging their raw value.
Builds an array of tokens by merging their raw value.
Gets the next token. Skips any irrelevant token (whitespaces and comments).
Gets the previous token. Skips any irrelevant token (whitespaces and comments).
Gets the previous token.
Gets the next token.
Gets the next token.
Gets the next token.
Sets an value inside the container.
Gets a value from the container.
Checks if an offset was previously set.
Unsets the value of an offset.
Details
__construct(array $tokens = [])
No description
string
build()
Builds an array of tokens by merging their raw value.
static string
buildFromArray(array $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
getPrevious()
Gets the previous token. Skips any irrelevant token (whitespaces and comments).
Token|null
getPreviousOfType(TokenType|array $type)
Gets the previous token.
Token|null
getNextOfType(TokenType|array $type)
Gets the next token.
Token|null
getNextOfTypeAndValue(TokenType $type, string $value)
Gets the next token.
Token|null
getNextOfTypeAndFlag(TokenType $type, int $flag)
Gets the next token.
void
offsetSet(mixed $offset, mixed $value)
Sets an value inside the container.
Token|null
offsetGet(mixed $offset)
Gets a value from the container.
bool
offsetExists(mixed $offset)
Checks if an offset was previously set.
void
offsetUnset(mixed $offset)
Unsets the value of an offset.