Esempio n. 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);
         }
     }
 }