Same name and namespace in other branches
  1. 6.0.x advagg_js_minify/jspacker.inc \ParseMaster::add() 1 commentaire
  2. 7.x-1.x advagg_js_compress/jspacker.inc \ParseMaster::add() 1 commentaire
  3. 7.x-2.x advagg_js_compress/jspacker.inc \ParseMaster::add() 1 commentaire
  4. 8.x-2.x advagg_js_minify/jspacker.inc \ParseMaster::add() 1 commentaire
  5. 8.x-3.x advagg_js_minify/jspacker.inc \ParseMaster::add() 1 commentaire
  6. 8.x-4.x advagg_js_minify/jspacker.inc \ParseMaster::add() 1 commentaire

Fichier

advagg_js_minify/jspacker.inc, line 595

Classe

ParseMaster

Code

public function add($expression, $replacement = '') {
    // count the number of sub-expressions
    //  - add one because each pattern is itself a sub-expression
    $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string) $expression), $out);
    // treat only strings $replacement
    if (is_string($replacement)) {
        // does the pattern deal with sub-expressions?
        if (preg_match($this->SUB_REPLACE, $replacement)) {
            // a simple lookup? (e.g. "$2")
            if (preg_match($this->INDEXED, $replacement)) {
                // store the index (used for fast retrieval of matched strings)
                $replacement = (int) substr($replacement, 1) - 1;
            }
            else {
                // a complicated lookup (e.g. "Hello $2 $1")
                // build a function to do the lookup
                $quote = preg_match($this->QUOTE, $this->_internalEscape($replacement)) ? '"' : "'";
                $replacement = array(
                    'fn' => '_backReferences',
                    'data' => array(
                        'replacement' => $replacement,
                        'length' => $length,
                        'quote' => $quote,
                    ),
                );
            }
        }
    }
    // pass the modified arguments
    if (!empty($expression)) {
        $this->_add($expression, $replacement, $length);
    }
    else {
        $this->_add('/^$/', $replacement, $length);
    }
}