Cursor
Constants
INDENT_LEVEL
Properties
$line
$length
$currentPosition int
<p>It's possible for this to be 1 char past the end, meaning we've parsed all chars and have reached the end. In this state, any character-returning method MUST return null.</p>
$column
$indent
$previousPosition
$nextNonSpaceCache
$partiallyConsumedTab
$lineContainsTabs
$isMultibyte
$charCache
array
Methods
__construct ( string $line ) : void
Parameters
-
$line
string
The line being parsed (ASCII or UTF-8)
getNextNonSpacePosition ( ) : void
Returns the position of the next character which is not a space (or tab)
getNextNonSpaceCharacter ( ) : void
Returns the next character which isn't a space (or tab)
getIndent ( ) : void
Calculates the current indent (number of spaces after current position)
isIndented ( ) : void
Whether the cursor is indented to INDENT_LEVEL
getCharacter ( int $index ) : void
getCurrentCharacter ( ) : void
Slightly-optimized version of getCurrent(null)
peek ( int $offset ) : void
Returns the next character (or null, if none) without advancing forwards
isBlank ( ) : void
Whether the remainder is blank
advance ( ) : void
Move the cursor forwards
advanceBy ( int $characters , bool $advanceByColumns ) : void
Move the cursor forwards
Parameters
-
$characters
int
Number of characters to advance by
-
$advanceByColumns
bool
Whether to advance by columns instead of spaces
advanceWithoutTabCharacters ( int $characters ) : void
advanceBySpaceOrTab ( ) : void
Advances the cursor by a single space or tab, if present
advanceToNextNonSpaceOrTab ( ) : int
Parse zero or more space/tab characters
advanceToNextNonSpaceOrNewline ( ) : int
Parse zero or more space characters, including at most one newline.
advanceToEnd ( ) : int
Move the position to the very end of the line
getRemainder ( ) : void
getLine ( ) : void
isAtEnd ( ) : void
match ( string $regex ) : void
Try to match a regular expression
saveState ( ) : void
Encapsulates the current state of this cursor in case you need to rollback later.