PHP Class PhpParser\Comment

Show file Open project: nikic/php-parser Class Usage Examples

Protected Properties

Property Type Description
$filePos
$line
$text

Public Methods

Method Description
__construct ( string $text, integer $startLine, integer $startFilePos ) Constructs a comment node.
__toString ( ) : string Gets the comment text.
getFilePos ( ) : integer Gets the file offset the comment started on.
getLine ( ) : integer Gets the line number the comment started on.
getReformattedText ( ) : mixed | string Gets the reformatted comment text.
getText ( ) : string Gets the comment text.
jsonSerialize ( )

Private Methods

Method Description
getShortestWhitespacePrefixLen ( $str )

Method Details

__construct() public method

Constructs a comment node.
public __construct ( string $text, integer $startLine, integer $startFilePos )
$text string Comment text (including comment delimiters like /*)
$startLine integer Line number the comment started on
$startFilePos integer File offset the comment started on

__toString() public method

Gets the comment text.
public __toString ( ) : string
return string The comment text (including comment delimiters like /*)

getFilePos() public method

Gets the file offset the comment started on.
public getFilePos ( ) : integer
return integer File offset

getLine() public method

Gets the line number the comment started on.
public getLine ( ) : integer
return integer Line number

getReformattedText() public method

"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.
public getReformattedText ( ) : mixed | string
return mixed | string

getText() public method

Gets the comment text.
public getText ( ) : string
return string The comment text (including comment delimiters like /*)

jsonSerialize() public method

public jsonSerialize ( )

Property Details

$filePos protected property

protected $filePos

$line protected property

protected $line

$text protected property

protected $text