Exemple #1
0
 /**
  * Quotes symbols to strings.
  * @return MacroTokens
  */
 public function quoteFilter(MacroTokens $tokens)
 {
     $res = new MacroTokens();
     while ($tokens->nextToken()) {
         $res->append($tokens->isCurrent(MacroTokens::T_SYMBOL) && (!$tokens->isPrev() || $tokens->isPrev(',', '(', '[', '=>', ':', '?', '.', '<', '>', '<=', '>=', '===', '!==', '==', '!=', '<>', '&&', '||', '=', 'and', 'or', 'xor')) && (!$tokens->isNext() || $tokens->isNext(',', ';', ')', ']', '=>', ':', '?', '.', '<', '>', '<=', '>=', '===', '!==', '==', '!=', '<>', '&&', '||', 'and', 'or', 'xor')) ? "'" . $tokens->currentValue() . "'" : $tokens->currentToken());
     }
     return $res;
 }