getGetter() public static method

Return true if the ending quote of the string is escaped.
public static getGetter ( object | array $anything, $key ) : string
$anything object | array object or array (PHP >= 7) that contains a callable
return string
Exemplo n.º 1
0
 protected function replaceInterpolationsInStrings($match)
 {
     $quote = $match[1];
     return str_replace('\\#{', '#{', preg_replace_callback('/(?<!\\\\)#{([^}]+)}/', function ($match) use($quote) {
         return $quote . ' . ' . CommonUtils::addDollarIfNeeded(preg_replace_callback('/(?<![a-zA-Z0-9_\\$])(\\$?[a-zA-Z_][a-zA-Z0-9_]*)\\.([a-zA-Z_][a-zA-Z0-9_]*)(?![a-zA-Z0-9_])/', function ($match) {
             return CommonUtils::getGetter($match[1], $match[2]);
         }, $match[1])) . ' . ' . $quote;
     }, $match[0]));
 }
Exemplo n.º 2
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;
 }