Base::compile PHP Method

compile() public method

Convert JS-style token to PHP expression
public compile ( $str ) : string
$str string
return string
    function compile($str)
    {
        $fw = $this;
        return preg_replace_callback('/(?<!\\w)@(\\w(?:[\\h\\w\\.\\[\\]\\(]|\\->|::)*)/', function ($var) use($fw) {
            return '$' . preg_replace_callback('/\\.(\\w+)\\(|\\.(\\w+)|\\[((?:[^\\[\\]]*|(?R))*)\\]/', function ($expr) use($fw) {
                return $expr[1] ? (function_exists($expr[1]) ? '.' . $expr[1] : '[' . var_export($expr[1], TRUE) . ']') . '(' : '[' . (isset($expr[3]) ? strlen($expr[3]) ? var_export(trim($fw->compile($expr[3])), TRUE) : '' : var_export(ctype_digit($expr[2]) ? (int) $expr[2] : $expr[2], TRUE)) . ']';
            }, $var[1]);
        }, $str);
    }