Parse the comment into the component parts and set the state of the object.
@param string $comment The docblock
@return TagCollection
554617
public function parseComment($comment)
    {
        preg_match_all('/@([a-zA-Z]+) *(.*)\n/', $comment, $matches, PREG_SET_ORDER);
        $tags = new TagCollection();

        foreach ($matches as $match) {
            array_shift($match);
            list($tag, $body) = $match;

            $tags->addTag($this->getTagEntity($tag, $body));
        }

        return $tags;
    }
1354276
public function addExtractedComment($comment)
    {
        if (!\in_array($comment, $this->extractedComments, true)) {
            $this->extractedComments[] = $comment;
        }

        return $this;
    }
1025189
private function resolveAnnotations($comment)
    {
        if (!$comment) {
            return [];
        }

        $comment = $this->cleanAnnotations($comment);
        $annotations = $this->splitAnnotations($comment);
        $annotations = $this->cleanContents($annotations);
        $annotations = $this->parseAnnotations($annotations);

        return $annotations;
    }
816207
public function isArray($comment = "")
	{
		if ($this->isValid)
		{
			if (!is_array($this->val))
				self::addMessage($comment);
		}

		return $this;
	}
1130211
public function addComment($comment)
    {
        if ($this->comments === null) {
            $this->comments = [];
        }
        $this->comments[] = $comment;
    }
1015017
protected function parseComment($fusionLine)
    {
        if (preg_match(self::SPLIT_PATTERN_COMMENTTYPE, $fusionLine, $matches, PREG_OFFSET_CAPTURE) === 1) {
            switch ($matches[1][0]) {
                case '/*':
                    $this->currentBlockCommentState = true;
                    break;
                case '*/':
                    if ($this->currentBlockCommentState !== true) {
                        throw new Fusion\Exception('Unexpected closing block comment without matching opening block comment.', 1180615119);
                    }
                    $this->currentBlockCommentState = false;
                    $this->parseFusionLine(substr($fusionLine, ($matches[1][1] + 2)));
                    break;
                case '#':
                case '//':
                default:
                    break;
            }
        } elseif ($this->currentBlockCommentState === false) {
            throw new Fusion\Exception('No comment type matched although the comment scan regex matched the Fusion line (' . $fusionLine . ').', 1180614895);
        }
    }
780692
final protected function parseDocComment($docComment, $docType = '') {
        if (empty($docComment) || !is_string($docComment))
            return array();

        $annotations = array();
        $match = '#@' . stripslashes($docType) . '(.*?)\n#s';
        preg_match_all($match, $docComment, $annotations);
        return $annotations[1];
    }
57109
protected function parseBlockCommentTags(array &$blockCommentLines)
    {
        $tags = array();
        $currentTagName = $currentTagContent = null;
        foreach ($blockCommentLines as $index => $blockCommentLine) {
            $isTagLine = preg_match(
                '~^@(\w+)(?:\s+(.*))?\s*$~',
                $blockCommentLine,
                $matches
            );
            $isEmptyLine = '' === trim($blockCommentLine);

            if (
                ($isTagLine || $isEmptyLine) &&
                null !== $currentTagName
            ) {
                if ('' === $currentTagContent) {
                    $currentTagContent = null;
                }
                $tags[] = new Element\DocumentationTag(
                    $currentTagName,
                    $currentTagContent
                );

                $currentTagName = $currentTagContent = null;
            }

            if ($isTagLine) {
                $currentTagName = $matches[1];
                $currentTagContent = '';
                if (array_key_exists(2, $matches)) {
                    $currentTagContent = $matches[2];
                }
            } elseif (!$isEmptyLine) {
                $currentTagContent .= ' ' . ltrim($blockCommentLine);
            }

            if (null !== $currentTagName || count($tags) > 0) {
                unset($blockCommentLines[$index]);
            }
        }
        if (null !== $currentTagName) {
            if ('' === $currentTagContent) {
                $currentTagContent = null;
            }
            $tags[] = new Element\DocumentationTag(
                $currentTagName,
                $currentTagContent
            );
        }

        return $tags;
    }
1118384
public function uncomment($comment = '#')
    {
        $commentLength = strlen($comment);
        foreach( $this->lines as &$line ) {
            if( 0 === strpos($line, $comment) ) {
                $line = substr( $line, $commentLength );
            }
        }
        return $this;
    }
923782
public function parse($commentString, $target)
    {
        // Extract the description part of the comment block
        $commentString = $this->stripCommentDecoration($commentString);
        $parts         = preg_split('/^\s*(?=@[a-zA-Z]+)/m', $commentString, 2);

        $comment = new Comment(trim($parts[0]));

        if (!isset($parts[1])) {
            return $comment;
        }
        $trimmed = trim($parts[1]);
        if (empty($trimmed)) {
            return $comment;
        }

        $pattern        = '/(\'(?:\\\\.|[^\'\\\\])*\'|"(?:\\\\.|[^"\\\\])*"|[@(),={}]|\s+|(?<![:])[:](?![:]))/';
        $flags          = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY;
        $this->parts    = preg_split($pattern, $parts[1], -1, $flags);
        $this->position = -1;

        while (isset($this->parts[ ++$this->position ])) {
            if ($this->parts[ $this->position ] === '@') {
                list($name, $parameters, $isClass) = $this->parseTag();
                if ($isClass) {
                    $className = $this->getFullyQualifiedName($name);

                    $this->saveState();
                    $comment->addAnnotation(
                        $className,
                        $this->container->readClass($className, $parameters, $target)
                    );
                    $this->restoreState();
                } else {
                    $comment->add($name, $parameters);
                }
            }
        }

        return $comment;
    }
202622
private function _processComment($token) {
		// Count the lines of comment
		if ($token->id === T_COMMENT) {
			$this->_ncssTotalSingleComment ++;
			$this->_ncssFileSingleComment ++;
		} else if ($token->id === T_ML_COMMENT) {
			$this->_ncssTotalMultiComment ++;
			$this->_ncssFileMultiComment ++;
		} else if ($token->id === T_DOC_COMMENT) {
			$this->_ncssTotalPhpdoc ++;
			$this->_ncssFilePhpdoc ++;
			$this->_ncssTotalLinesPhpdoc ++;
			$this->_ncssFileLinesPhpdoc ++;
			if ($this->_isFileDocComment()) {
				$this->_processAnnotation(T_FILE, $token->text);
			}
		}

		// Count the @params, @returns and @throw
		if (stripos($token->text, '/**') !== false) {
			// Reset the count of elements if it's a new docblock
			$this->statementStack->getCurrentStackItem()->docblocNbParams = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbReturns = 0;
			$this->statementStack->getCurrentStackItem()->docblocNbThrows = 0;
		}
		if (stripos($token->text, '@param') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbParams ++;
		}
		if (stripos($token->text, '@return') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbReturns ++;
		}
		if (stripos($token->text, '@throw') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocNbThrows ++;
		}
		if (stripos($token->text, '@inheritdoc') !== false) {
			$this->statementStack->getCurrentStackItem()->docblocInheritDoc = true;
		}

		// Check if the comment starts with '#'
		if ($this->_isActive('noShellComments')) {
			$todoStr = strpos($token->text, '#');
			if ($todoStr === 0) {
				$this->_writeError('noShellComments', $this->_getMessage('NO_SHELL_COMMENTS'));
			}
		}

		// Check if the comment contains a TO DO
		$this->_processTODO($token);
	}
687787
public static function add_comment(comment $comment) {
        global $DB;
        $comment->id = null;
        return $DB->insert_record('assignfeedback_editpdf_cmnt', $comment);
    }
67482
private function cleanAnnotations($comment)
    {
        $comment = trim(
            preg_replace(
                '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
                '$1',
                $comment
            )
        );

        // reg ex above is not able to remove */ from a single line docblock
        if (substr($comment, -2) == '*/') {
            $comment = trim(substr($comment, 0, -2));
        }

        // normalize strings
        $comment = str_replace(["\r\n", "\r"], "\n", $comment);

        return $comment;
    }
614335
protected function setComment($comment)
    {
        $this->desc    = '';
        $this->tags    = [];
        $this->comment = $comment;

        $this->parseComment($comment);
    }
1087061
protected function parseCommentLine( Line$line ):self
	{
		$node= new CommentNode($this,$line);

		return $this->openNode($node)->appendLine($node->open());
	}
1374612
protected function outputComment($comment)
	{
		if ($this->commentOptions instanceof \Closure) {
			$options = call_user_func($this->commentOptions, $comment);
		} else {
			$options = $this->commentOptions;
		}
		$options = ArrayHelper::merge($options, ['data-comment-id'=>$comment->id]);
		if ($this->useBootstrapClasses) Html::addCssClass($options, 'media');

		//render comment
		echo Html::beginTag('div', $options);

			//body
			$wrapperOptions = ['class'=>'comment-wrapper'];
			if ($this->useBootstrapClasses) Html::addCssClass($wrapperOptions, 'media-body');
			echo Html::beginTag('div', $wrapperOptions);

				//title
				if (!empty($comment->title)) {
					$titleOptions = ['class'=>'comment-title'];
					if ($this->useBootstrapClasses) Html::addCssClass($titleOptions, 'media-heading');
					$title = $this->encodeCommentTitle ? Html::encode($comment->title) : $comment->title;
					echo Html::tag($this->commentTitleTag, $title, $titleOptions);
				}

				//content
				$content = $this->encodeCommentContents ? Html::encode($comment->content) : $comment->content;
				echo Html::tag('div', $content, ['class'=>'comment-content']);

				//meta
				echo Html::beginTag('dl', ['class'=>'comment-meta']);
				echo Html::tag('dt', Yii::t('app', 'Created'));
				echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->created));
				if (!empty($comment->updated) && $comment->updated != $comment->created) {
					echo Html::tag('dt', Yii::t('app', 'Updated'));
					echo Html::tag('dd', Yii::$app->formatter->asDatetime($comment->updated));
				}
				if (!empty($comment->user_id)) {
					$author = $this->authorCallback === null ? $comment->created_by : call_user_func($this->authorCallback, $comment->created_by);
					echo Html::tag('dt', Yii::t('app', 'Author'));
					echo Html::tag('dd', $author);
				}
				echo Html::endTag('dl');

			echo Html::endTag('div');
		echo Html::endTag('div');
	}
527841
protected function prepare_links( $comment ) {
		$links = array(
			'self' => array(
				'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID ) ),
			),
			'collection' => array(
				'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
		);

		if ( 0 !== (int) $comment->user_id ) {
			$links['author'] = array(
				'href'       => rest_url( 'wp/v2/users/' . $comment->user_id ),
				'embeddable' => true,
			);
		}

		if ( 0 !== (int) $comment->comment_post_ID ) {
			$post = $this->get_post( $comment->comment_post_ID );
			if ( ! empty( $post->ID ) ) {
				$obj = get_post_type_object( $post->post_type );
				$base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;

				$links['up'] = array(
					'href'       => rest_url( 'wp/v2/' . $base . '/' . $comment->comment_post_ID ),
					'embeddable' => true,
					'post_type'  => $post->post_type,
				);
			}
		}

		if ( 0 !== (int) $comment->comment_parent ) {
			$links['in-reply-to'] = array(
				'href'       => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_parent ) ),
				'embeddable' => true,
			);
		}

		// Only grab one comment to verify the comment has children.
		$comment_children = $comment->get_children( array( 'number' => 1, 'count' => true ) );
		if ( ! empty( $comment_children ) ) {
			$args = array( 'parent' => $comment->comment_ID );
			$rest_url = add_query_arg( $args, rest_url( $this->namespace . '/' . $this->rest_base ) );

			$links['children'] = array(
				'href' => $rest_url,
			);
		}

		return $links;
	}