Jade\Compiler\CommonUtils::addDollarIfNeeded PHP Method

addDollarIfNeeded() public static method

public static addDollarIfNeeded ( string $call ) : string
$call string
return string
    public static function addDollarIfNeeded($call)
    {
        if ($call === 'Inf') {
            throw new \InvalidArgumentException($call . ' cannot be read from PHP', 16);
        }
        if ($call === 'undefined') {
            return 'null';
        }
        $firstChar = substr($call, 0, 1);
        if (!in_array($firstChar, array('$', '\\')) && !preg_match('#^(?:' . CompilerConfig::VARNAME . '\\s*\\(|(?:null|false|true)(?![a-z]))#i', $call) && preg_match('#^(_*' . CompilerConfig::VARNAME . ')(?!\\()#', $call)) {
            $call = '$' . $call;
        }
        return $call;
    }

Usage Example

Esempio 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]));
 }
All Usage Examples Of Jade\Compiler\CommonUtils::addDollarIfNeeded