Provides operations on token streams, for use by pretty printer.
- internal
Methods |
public __construct(array $tokens, int $tabWidth) Create token stream instance.
|
public findRight(int $pos, $findTokenType) : int
|
public getIndentationBefore(int $pos) : int Get indentation before token position.
|
public getTokenCode(int $from, int $to, int $indent) : string Get the code corresponding to a token offset range, optionally adjusted for indentation.
|
public haveBraces(int $startPos, int $endPos) : bool Whether the given position is immediately surrounded by braces.
|
public haveParens(int $startPos, int $endPos) : bool Whether the given position is immediately surrounded by parenthesis.
|
public haveTagInRange(int $startPos, int $endPos) : bool |
public haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool Check whether the position is directly followed by a certain token type. During this check whitespace and comments are skipped.
|
public haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool Check whether the position is directly preceded by a certain token type. During this check whitespace and comments are skipped.
|
public haveTokenInRange(int $startPos, int $endPos, $tokenType) : bool Whether the given position range contains a certain token type.
|
public skipLeft(int $pos, $skipTokenType) : int
|
public skipLeftWhitespace(int $pos) : int Return first non-whitespace token position smaller or equal to passed position.
|
public skipRight(int $pos, $skipTokenType) : int
|
public skipRightWhitespace(int $pos) : int Return first non-whitespace position greater or equal to passed position.
|
Properties |
private array $indentMap
|
private array $tokens
|
Methods |
private calcIndentMap(int $tabWidth) : array Precalculate the indentation at every token position.
|
private getIndent(string $ws, int $tabWidth) : int |