示例#1
0
 /**
  * Pseudocast (expand).
  * @return MacroTokens
  */
 public function expandFilter(MacroTokens $tokens)
 {
     $res = new MacroTokens('array(');
     $expand = NULL;
     while ($tokens->nextToken()) {
         if ($tokens->isCurrent('(expand)') && $tokens->depth === 0) {
             $expand = TRUE;
             $res->append('),');
         } elseif ($expand && $tokens->isCurrent(',') && !$tokens->depth) {
             $expand = FALSE;
             $res->append(', array(');
         } else {
             $res->append($tokens->currentToken());
         }
     }
     if ($expand !== NULL) {
         $res->prepend('array_merge(')->append($expand ? ', array()' : ')');
     }
     return $res->append(')');
 }