class ParsedDocComment
@internal
Hierarchy
- class \SlevomatCodingStandard\Helpers\ParsedDocComment
Expanded class hierarchy of ParsedDocComment
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ ParsedDocComment.php, line 19
Namespace
SlevomatCodingStandard\HelpersView source
class ParsedDocComment {
/** @var int */
private $openPointer;
/** @var int */
private $closePointer;
/** @var PhpDocNode */
private $node;
/** @var TokenIterator */
private $tokens;
public function __construct(int $openPointer, int $closePointer, PhpDocNode $node, TokenIterator $tokens) {
$this->openPointer = $openPointer;
$this->closePointer = $closePointer;
$this->node = $node;
$this->tokens = $tokens;
}
public function getOpenPointer() : int {
return $this->openPointer;
}
public function getClosePointer() : int {
return $this->closePointer;
}
public function getNode() : PhpDocNode {
return $this->node;
}
public function getTokens() : TokenIterator {
return $this->tokens;
}
public function getNodeStartPointer(File $phpcsFile, Node $node) : int {
$tokens = $phpcsFile->getTokens();
$tagStartLine = $tokens[$this->openPointer]['line'] + $node->getAttribute('startLine') - 1;
$searchPointer = $this->openPointer + 1;
for ($i = $this->openPointer + 1; $i < $this->closePointer; $i++) {
if ($tagStartLine === $tokens[$i]['line']) {
$searchPointer = $i;
break;
}
}
return TokenHelper::findNext($phpcsFile, array_merge(TokenHelper::$annotationTokenCodes, [
T_DOC_COMMENT_STRING,
]), $searchPointer);
}
public function getNodeEndPointer(File $phpcsFile, Node $node, int $nodeStartPointer) : int {
$tokens = $phpcsFile->getTokens();
$content = trim($this->tokens
->getContentBetween($node->getAttribute(Attribute::START_INDEX), $node->getAttribute(Attribute::END_INDEX) + 1));
$length = strlen($content);
$searchPointer = $nodeStartPointer;
$content = '';
for ($i = $nodeStartPointer; $i < count($tokens); $i++) {
$content .= $tokens[$i]['content'];
if (strlen($content) >= $length) {
$searchPointer = $i;
break;
}
}
return TokenHelper::findPrevious($phpcsFile, array_merge(TokenHelper::$annotationTokenCodes, [
T_DOC_COMMENT_STRING,
]), $searchPointer);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ParsedDocComment::$closePointer | private | property | @var int |
ParsedDocComment::$node | private | property | @var PhpDocNode |
ParsedDocComment::$openPointer | private | property | @var int |
ParsedDocComment::$tokens | private | property | @var TokenIterator |
ParsedDocComment::getClosePointer | public | function | |
ParsedDocComment::getNode | public | function | |
ParsedDocComment::getNodeEndPointer | public | function | |
ParsedDocComment::getNodeStartPointer | public | function | |
ParsedDocComment::getOpenPointer | public | function | |
ParsedDocComment::getTokens | public | function | |
ParsedDocComment::__construct | public | function |