Пример #1
0
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\AbstractObject $object
  * @param \PhpParser\Node\Stmt $node
  */
 protected function addCommentAttributes(\EBT\ExtensionBuilder\Domain\Model\AbstractObject $object, \PhpParser\Node\Stmt $node)
 {
     $commentAttributes = array();
     $comments = $object->getComments();
     if (count($comments) > 0) {
         foreach ($comments as $comment) {
             $commentAttributes[] = new \PhpParser\Comment($comment);
         }
     }
     if ($object->hasDescription() || $object->hasTags()) {
         $commentAttributes[] = new \PhpParser\Comment\Doc($object->getDocComment());
     }
     $node->setAttribute('comments', $commentAttributes);
 }
Пример #2
0
 /**
  * @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);
 }