protected function setComment(NodeInterface $node, $comment_text) { if ($this->supportsDocComments($node)) { /** @var \Pharborist\DocCommentTrait $node */ $node->setDocComment(DocCommentNode::create($comment_text)); } else { LineCommentBlockNode::create($comment_text)->insertBefore($node->getStatement()); } }
/** * Builds a FIXME notice using either the text in the plugin definition, * or passed-in text. * * @param string|NULL $text * The FIXME notice's text, with variable placeholders and no translation. * @param array $variables * Optional variables to use in translation. If empty, the FIXME will not * be translated. * @param string|NULL $style * The comment style. Returns a LineCommentBlockNode if this is set to * self::LINE_COMMENT, a DocCommentNode if self::DOC_COMMENT, or the FIXME * as a string if set to anything else. * * @return mixed */ protected function buildFixMe($text = NULL, array $variables = [], $style = self::LINE_COMMENT) { $fixMe = "@FIXME\n" . ($text ?: $this->pluginDefinition['fixme']); if (isset($this->pluginDefinition['documentation'])) { $fixMe .= "\n"; foreach ($this->pluginDefinition['documentation'] as $doc) { $fixMe .= "\n@see "; $fixMe .= isset($doc['url']) ? $doc['url'] : (string) $doc; } } if ($variables) { $fixMe = $this->t($fixMe, $variables); } switch ($style) { case self::LINE_COMMENT: return LineCommentBlockNode::create($fixMe); case self::DOC_COMMENT: return DocCommentNode::create($fixMe); default: return $fixMe; } }