function NodeAbstract::setDocComment
Sets the doc comment of the node.
This will either replace an existing doc comment or add it to the comments array.
Parameters
Comment\Doc $docComment Doc comment to set:
Overrides Node::setDocComment
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ NodeAbstract.php, line 135
Class
Namespace
PhpParserCode
public function setDocComment(Comment\Doc $docComment) : void {
$comments = $this->getComments();
for ($i = count($comments) - 1; $i >= 0; $i--) {
if ($comments[$i] instanceof Comment\Doc) {
// Replace existing doc comment.
$comments[$i] = $docComment;
$this->setAttribute('comments', $comments);
return;
}
}
// Append new doc comment.
$comments[] = $docComment;
$this->setAttribute('comments', $comments);
}