/** * @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); }
/** * 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); } } }