Common static methods for compiler and lexer classes.
Пример #1
0
 /**
  * Return PHP code to translate dot to object/array getter.
  *
  * @example foo.bar return $foo->bar (if foo is an object), or $foo["bar"] if it's an array.
  *
  * @param array $match regex match
  *
  * @return string
  */
 protected static function convertVarPathCallback($match)
 {
     if (empty($match[1])) {
         return $match[0];
     }
     $var = ($match[0] === ',' ? ',' : '') . $match[1];
     foreach (explode('.', substr($match[2], 1)) as $name) {
         if (!empty($name)) {
             $var = CommonUtils::getGetter($var, $name, false);
         }
     }
     return $var;
 }
Пример #2
0
 protected function parseString(&$states, &$key, &$val, &$quote, $char)
 {
     if (($char === '"' || $char === "'") && !CommonUtils::escapedEnd($val)) {
         $stringParser = new StringAttribute($char);
         $stringParser->parse($states, $val, $quote);
         return;
     }
     ${in_array($states->current(), array('key', 'key char')) ? 'key' : 'val'} .= $char;
 }