Copied!
CloneableInstantiable
Methods
public __construct(string $text, int $startLine = -1, int $startFilePos = -1, int $startTokenPos = -1, int $endLine = -1, int $endFilePos = -1, int $endTokenPos = -1)
 

Constructs a comment node.

  • param string $text Comment text (including comment delimiters like /*)
  • param int $startLine Line number the comment started on
  • param int $startFilePos File offset the comment started on
  • param int $startTokenPos Token offset the comment started on
public __toString() : string
 

Gets the comment text.

  • return string The comment text (including comment delimiters like /*)
public getEndFilePos() : int
 

Gets the file offset the comment ends on.

  • return int File offset (or -1 if not available)
public getEndLine() : int
 

Gets the line number the comment ends on.

  • return int Line number (or -1 if not available)
public getEndTokenPos() : int
 

Gets the token offset the comment ends on.

  • return int Token offset (or -1 if not available)
public getReformattedText() : string
 

Gets the reformatted comment text.

"Reformatted" here means that we try to clean up the whitespace at the starts of the lines. This is necessary because we receive the comments without leading whitespace on the first line, but with leading whitespace on all subsequent lines.

Additionally, this normalizes CRLF newlines to LF newlines.

public getStartFilePos() : int
 

Gets the file offset the comment started on.

  • return int File offset (or -1 if not available)
public getStartLine() : int
 

Gets the line number the comment started on.

  • return int Line number (or -1 if not available)
public getStartTokenPos() : int
 

Gets the token offset the comment started on.

  • return int Token offset (or -1 if not available)
public getText() : string
 

Gets the comment text.

  • return string The comment text (including comment delimiters like /*)
public jsonSerialize() : array
 
  • return array{nodeType: string, text: mixed, line: mixed, filePos: mixed}
Properties
protected int $endFilePos
protected int $endLine
protected int $endTokenPos
protected int $startFilePos
protected int $startLine
protected int $startTokenPos
protected string $text
Methods
private getShortestWhitespacePrefixLen(string $str) : int
 

Get length of shortest whitespace prefix (at the start of a line).

If there is a line with no prefix whitespace, 0 is a valid return value.

  • param string $str String to check
  • return int Length in characters. Tabs count as single characters.
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration