Same name in other branches
  1. 5.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()
  2. 6.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()
  3. 7.x-2.x advagg_js_compress/jshrink.inc \JShrink\Minifier::lock()
  4. 8.x-2.x advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()
  5. 8.x-3.x advagg_js_minify/jshrink.inc \JShrink\Minifier::lock()

Replace patterns in the given string and store the replacement

Parameters

string $js The string to lock:

Return value

bool

File

advagg_js_minify/jshrink.inc, line 591

Class

Minifier
Minifier

Namespace

JShrink

Code

protected function lock($js) {
    
    /* lock things like <code>"asd" + ++x;</code> */
    $lock = '"LOCK---' . crc32(time()) . '"';
    $matches = array();
    preg_match('/([+-])(\\s+)([+-])/S', $js, $matches);
    if (empty($matches)) {
        return $js;
    }
    $this->locks[$lock] = $matches[2];
    $js = preg_replace('/([+-])\\s+([+-])/S', "\$1{$lock}\$2", $js);
    
    /* -- */
    return $js;
}