Copied!

Provides operations on token streams, for use by pretty printer.

  • internal
Cloneable Instantiable
Methods
public __construct ( array $tokens )
 

Create token stream instance.

public findRight ( int $pos , $findTokenType )
public getIndentationBefore ( int $pos ) : int
 

Get indentation before token position.

  • return int Indentation depth (in spaces)
public getTokenCode ( int $from , int $to , int $indent ) : string
 

Get the code corresponding to a token offset range, optionally adjusted for indentation.

  • return string Code corresponding to token range, adjusted for indentation
public haveBraces ( int $startPos , int $endPos ) : bool
 

Whether the given position is immediately surrounded by braces.

  • return bool
public haveBracesInRange ( int $startPos , int $endPos )
public haveParens ( int $startPos , int $endPos ) : bool
 

Whether the given position is immediately surrounded by parenthesis.

  • return 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.

  • return bool Whether the expected token was found
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.

  • return bool Whether the expected token was found
public haveTokenInRange ( int $startPos , int $endPos , $tokenType )
 

Whether the given position range contains a certain token type.

  • return bool Whether the token occurs in the given range
public skipLeft ( int $pos , $skipTokenType )
public skipLeftWhitespace ( int $pos )
 

Return first non-whitespace token position smaller or equal to passed position.

  • return int Non-whitespace token position
public skipRight ( int $pos , $skipTokenType )
public skipRightWhitespace ( int $pos )
 

Return first non-whitespace position greater or equal to passed position.

  • return int Non-whitespace token position
Properties
private $indentMap
 
  • var int [] Map from position to indentation
private $tokens
 
  • var array Tokens (in token_get_all format)
Methods
private calcIndentMap ()
 

Precalculate the indentation at every token position.

  • return int [] Token position to indentation map
© 2020 Bruce Wells
Search Namespaces \ Classes
Configuration Numbers (0-9.) only