Comment
in package
implements
JsonSerializable
Interfaces, Classes, Traits and Enums
- JsonSerializable
Table of Contents
- $endFilePos : mixed
- $endLine : mixed
- $endTokenPos : mixed
- $startFilePos : mixed
- $startLine : mixed
- $startTokenPos : mixed
- $text : mixed
- __construct() : mixed
- Constructs a comment node.
- __toString() : string
- Gets the comment text.
- getEndFilePos() : int
- Gets the file offset the comment ends on.
- getEndLine() : int
- Gets the line number the comment ends on.
- getEndTokenPos() : int
- Gets the token offset the comment ends on.
- getFilePos() : int
- Gets the file offset the comment started on.
- getLine() : int
- Gets the line number the comment started on.
- getReformattedText() : mixed|string
- Gets the reformatted comment text.
- getStartFilePos() : int
- Gets the file offset the comment started on.
- getStartLine() : int
- Gets the line number the comment started on.
- getStartTokenPos() : int
- Gets the token offset the comment started on.
- getText() : string
- Gets the comment text.
- getTokenPos() : int
- Gets the token offset the comment started on.
- jsonSerialize() : array<string|int, mixed>
- getShortestWhitespacePrefixLen() : int
- Get length of shortest whitespace prefix (at the start of a line).
Properties
$endFilePos
protected
mixed
$endFilePos
$endLine
protected
mixed
$endLine
$endTokenPos
protected
mixed
$endTokenPos
$startFilePos
protected
mixed
$startFilePos
$startLine
protected
mixed
$startLine
$startTokenPos
protected
mixed
$startTokenPos
$text
protected
mixed
$text
Methods
__construct()
Constructs a comment node.
public
__construct(string $text[, int $startLine = -1 ][, int $startFilePos = -1 ][, int $startTokenPos = -1 ][, int $endLine = -1 ][, int $endFilePos = -1 ][, int $endTokenPos = -1 ]) : mixed
Parameters
- $text : string
-
Comment text (including comment delimiters like /*)
- $startLine : int = -1
-
Line number the comment started on
- $startFilePos : int = -1
-
File offset the comment started on
- $startTokenPos : int = -1
-
Token offset the comment started on
- $endLine : int = -1
- $endFilePos : int = -1
- $endTokenPos : int = -1
Return values
mixed —__toString()
Gets the comment text.
public
__toString() : string
Return values
string —The comment text (including comment delimiters like /*)
getEndFilePos()
Gets the file offset the comment ends on.
public
getEndFilePos() : int
Return values
int —File offset (or -1 if not available)
getEndLine()
Gets the line number the comment ends on.
public
getEndLine() : int
Return values
int —Line number (or -1 if not available)
getEndTokenPos()
Gets the token offset the comment ends on.
public
getEndTokenPos() : int
Return values
int —Token offset (or -1 if not available)
getFilePos()
Gets the file offset the comment started on.
public
getFilePos() : int
Tags
Return values
int —File offset
getLine()
Gets the line number the comment started on.
public
getLine() : int
Tags
Return values
int —Line number
getReformattedText()
Gets the reformatted comment text.
public
getReformattedText() : mixed|string
"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 trailing whitespace on the first line, but with trailing whitespace on all subsequent lines.
Return values
mixed|string —getStartFilePos()
Gets the file offset the comment started on.
public
getStartFilePos() : int
Return values
int —File offset (or -1 if not available)
getStartLine()
Gets the line number the comment started on.
public
getStartLine() : int
Return values
int —Line number (or -1 if not available)
getStartTokenPos()
Gets the token offset the comment started on.
public
getStartTokenPos() : int
Return values
int —Token offset (or -1 if not available)
getText()
Gets the comment text.
public
getText() : string
Return values
string —The comment text (including comment delimiters like /*)
getTokenPos()
Gets the token offset the comment started on.
public
getTokenPos() : int
Tags
Return values
int —Token offset
jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getShortestWhitespacePrefixLen()
Get length of shortest whitespace prefix (at the start of a line).
private
getShortestWhitespacePrefixLen(string $str) : int
If there is a line with no prefix whitespace, 0 is a valid return value.
Parameters
- $str : string
-
String to check
Return values
int —Length in characters. Tabs count as single characters.