Methods |
public
|
__construct(string $line)
Parameters
$line |
The line being parsed (ASCII or UTF-8)
|
|
#
|
public
|
getNextNonSpacePosition(): int
Returns the position of the next character which is not a space (or tab)
Returns the position of the next character which is not a space (or tab)
|
#
|
public
|
getNextNonSpaceCharacter(): ?string
Returns the next character which isn't a space (or tab)
Returns the next character which isn't a space (or tab)
|
#
|
public
|
getIndent(): int
Calculates the current indent (number of spaces after current position)
Calculates the current indent (number of spaces after current position)
|
#
|
public
|
isIndented(): bool
Whether the cursor is indented to INDENT_LEVEL
Whether the cursor is indented to INDENT_LEVEL
|
#
|
public
|
getCharacter(?int $index = null): ?string
|
#
|
public
|
getCurrentCharacter(): ?string
Slightly-optimized version of getCurrent(null)
Slightly-optimized version of getCurrent(null)
|
#
|
public
|
peek(int $offset = 1): ?string
Returns the next character (or null, if none) without advancing forwards
Returns the next character (or null, if none) without advancing forwards
|
#
|
public
|
isBlank(): bool
Whether the remainder is blank
Whether the remainder is blank
|
#
|
public
|
advance(): void
|
#
|
public
|
advanceBy(int $characters, bool $advanceByColumns = false): void
Parameters
$characters |
Number of characters to advance by
|
$advanceByColumns |
Whether to advance by columns instead of spaces
|
|
#
|
public
|
advanceBySpaceOrTab(): bool
Advances the cursor by a single space or tab, if present
Advances the cursor by a single space or tab, if present
|
#
|
public
|
advanceToNextNonSpaceOrTab(): int
Parse zero or more space/tab characters
Parse zero or more space/tab characters
Returns
Number of positions moved
|
#
|
public
|
advanceToNextNonSpaceOrNewline(): int
Parse zero or more space characters, including at most one newline. Tab characters are not parsed with this function.
Parse zero or more space characters, including at most one newline. Tab characters are not parsed with this function.
Returns
Number of positions moved
|
#
|
public
|
advanceToEnd(): int
Move the position to the very end of the line
Move the position to the very end of the line
Returns
The number of characters moved
|
#
|
public
|
getRemainder(): string
|
#
|
public
|
getLine(): string
|
#
|
public
|
isAtEnd(): bool
|
#
|
public
|
match(non-empty-string $regex): ?string
Try to match a regular expression Returns the matching text and advances to the end of that match
Try to match a regular expression Returns the matching text and advances to the end of that match
|
#
|
public
|
saveState(): CursorState
Encapsulates the current state of this cursor in case you need to rollback later. WARNING: Do not parse or use the return value for ANYTHING except for
passing it back into restoreState(), as the number of values and their
contents may change in any future release without warning.
Encapsulates the current state of this cursor in case you need to rollback later. WARNING: Do not parse or use the return value for ANYTHING except for
passing it back into restoreState(), as the number of values and their
contents may change in any future release without warning.
|
#
|
public
|
restoreState(CursorState $state): void
Restore the cursor to a previous state. Pass in the value previously obtained by calling saveState().
Restore the cursor to a previous state. Pass in the value previously obtained by calling saveState().
|
#
|
public
|
getPosition(): int
|
#
|
public
|
getPreviousText(): string
|
#
|
public
|
getSubstring(int $start, ?int $length = null): string
|
#
|
public
|
getColumn(): int
|
#
|