Copied!
CloneableInstantiable
Constants
public League\CommonMark\Parser\Cursor::INDENT_LEVEL = 4
Methods
public __construct(string $line)
 
  • param string $line The line being parsed (ASCII or UTF-8)
public advance() : void
 

Move the cursor forwards

public advanceBy(int $characters, bool $advanceByColumns = false) : void
 

Move the cursor forwards

  • param int $characters Number of characters to advance by
  • param bool $advanceByColumns Whether to advance by columns instead of spaces
public advanceBySpaceOrTab() : bool
 

Advances the cursor by a single space or tab, if present

public advanceToEnd() : int
 

Move the position to the very end of the line

  • return int The number of characters moved
public advanceToNextNonSpaceOrNewline() : int
 

Parse zero or more space characters, including at most one newline.

Tab characters are not parsed with this function.

  • return int Number of positions moved
public advanceToNextNonSpaceOrTab() : int
 

Parse zero or more space/tab characters

  • return int Number of positions moved
public getCharacter(?int $index = NULL) : ?string
public getColumn() : int
public getCurrentCharacter() : ?string
 

Slightly-optimized version of getCurrent(null)

public getIndent() : int
 

Calculates the current indent (number of spaces after current position)

public getLine() : string
public getNextNonSpaceCharacter() : ?string
 

Returns the next character which isn't a space (or tab)

public getNextNonSpacePosition() : int
 

Returns the position of the next character which is not a space (or tab)

public getPosition() : int
public getPreviousText() : string
public getRemainder() : string
public getSubstring(int $start, ?int $length = NULL) : string
public isAtEnd() : bool
public isBlank() : bool
 

Whether the remainder is blank

public isIndented() : bool
 

Whether the cursor is indented to INDENT_LEVEL

public match(string $regex) : ?string
 

Try to match a regular expression

Returns the matching text and advances to the end of that match

  • psalm-param non-empty-string $regex
public peek(int $offset = 1) : ?string
 

Returns the next character (or null, if none) without advancing forwards

public restoreState(League\CommonMark\Parser\CursorState $state) : void
 

Restore the cursor to a previous state.

Pass in the value previously obtained by calling saveState().

public saveState() : League\CommonMark\Parser\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.

Properties
private array $charCache = []
 
  • var array<int,string>
private int $column = 0
private int $currentPosition = 0
 
  • var int
private int $indent = 0
private bool $isMultibyte
 
  • psalm-readonly
private $lastTabPosition = NULL
 
  • var int|false
  • psalm-readonly
private int $length
 
  • psalm-readonly
private string $line
 
  • psalm-readonly
private ?int $nextNonSpaceCache = NULL
private bool $partiallyConsumedTab = false
private int $previousPosition = 0
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration