Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeAbstract.php

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

NodeAbstract

Namespace

PhpParser

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal