예제 #1
0
 /**
  * Extracts annotations in the comment of a statement and injects them in
  * attribute of the node
  *
  * @param \PHPParser_Node_Stmt $node
  */
 protected function extractAnnotation(\PHPParser_Node_Stmt $node)
 {
     if ($node->hasAttribute('comments')) {
         $compil = array();
         foreach ($node->getAttribute('comments') as $comm) {
             preg_match_all('#^.*@mondrian\\s+([\\w]+)\\s+([^\\s]+)\\s*$#m', $comm->getReformattedText(), $match);
             foreach ($match[0] as $idx => $matchedOccur) {
                 $compil[$match[1][$idx]][] = $match[2][$idx];
             }
         }
         // if there are annotations, we add them to the node
         foreach ($compil as $attr => $lst) {
             $node->setAttribute($attr, $lst);
         }
     }
 }
예제 #2
0
 /**
  * @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());
             }
         }
     }
 }