/** * @param \EBT\ExtensionBuilder\Domain\Model\AbstractObject $object * @param \PhpParser\Node\Stmt $node */ protected function addCommentsFromAttributes(Model\AbstractObject $object, \PhpParser\Node\Stmt $node) { $comments = $node->getAttribute('comments'); if (is_array($comments)) { foreach ($comments as $comment) { if ($comment instanceof \PhpParser\Comment\Doc) { $object->setDocComment($comment->getReformattedText()); } elseif ($comment instanceof \PhpParser\Comment) { $object->addComment($comment->getText()); } } } }
/** * @param \EBT\ExtensionBuilder\Domain\Model\AbstractObject $object * @param array $replacements */ protected function updateDocComment($object, $replacements) { $docComment = $object->getDocComment(); // reset all tags (they will be restored from the parsed doc comment string) $object->setTags(array()); $object->setDescriptionLines(array()); // replace occurences in tags and comments $pattern = array_keys($replacements); array_walk($pattern, function (&$item) { $item = '/' . $item . '/'; }); $parsedDocCommentString = preg_replace($pattern, array_values($replacements), $docComment); $object->setDocComment($parsedDocCommentString); }