Documentation

Doc extends Comment
in package

Table of Contents

Properties

$endFilePos  : int
$endLine  : int
$endTokenPos  : int
$startFilePos  : int
$startLine  : int
$startTokenPos  : int
$text  : string

Methods

__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.
getReformattedText()  : 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.
jsonSerialize()  : array{nodeType: string, text: mixed, line: mixed, filePos: mixed}
getShortestWhitespacePrefixLen()  : int
Get length of shortest whitespace prefix (at the start of a line).

Properties

$endFilePos

protected int $endFilePos

$endTokenPos

protected int $endTokenPos

$startFilePos

protected int $startFilePos

$startTokenPos

protected int $startTokenPos

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

__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)

getReformattedText()

Gets the reformatted comment text.

public getReformattedText() : 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 leading whitespace on the first line, but with leading whitespace on all subsequent lines.

Additionally, this normalizes CRLF newlines to LF newlines.

Return values
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 /*)

jsonSerialize()

public jsonSerialize() : array{nodeType: string, text: mixed, line: mixed, filePos: mixed}
Return values
array{nodeType: string, text: mixed, line: mixed, filePos: 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.


        
On this page

Search results