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

Skips multiline comments where appropriate, and includes them where needed. Conditional comments and "license" style blocks are preserved.

Paramètres

int $startIndex The index point where "getReal" function started:

Return value

bool|string False if there's no character

Throws

\RuntimeException Unclosed comments will throw an error

1 call to Minifier::processMultiLineComments()
Minifier::getReal dans advagg_js_minify/jshrink.inc
This function gets the next "real" character. It is essentially a wrapper around the getChar function that skips comments. This has significant performance benefits as the skipping is done using native functions (ie, c code) rather than in script php.

Fichier

advagg_js_minify/jshrink.inc, line 401

Classe

Minifier
Minifier

Namespace

JShrink

Code

protected function processMultiLineComments($startIndex) {
    $this->getChar();
    // current C
    $thirdCommentString = $this->getChar();
    // kill everything up to the next */ if it's there
    if ($this->getNext('*/')) {
        $this->getChar();
        // get *
        $this->getChar();
        // get /
        $char = $this->getChar();
        // get next real character
        // Now we reinsert conditional comments and YUI-style licensing comments
        if ($this->options['flaggedComments'] && $thirdCommentString === '!' || $thirdCommentString === '@') {
            // If conditional comments or flagged comments are not the first thing in the script
            // we need to echo a and fill it with a space before moving on.
            if ($startIndex > 0) {
                echo $this->a;
                $this->a = " ";
                // If the comment started on a new line we let it stay on the new line
                if ($this->input[$startIndex - 1] === "\n") {
                    echo "\n";
                }
            }
            $endPoint = $this->index - 1 - $startIndex;
            echo substr($this->input, $startIndex, $endPoint);
            return $char;
        }
    }
    else {
        $char = false;
    }
    if ($char === false) {
        throw new \RuntimeException('Unclosed multiline comment at position: ' . ($this->index - 2));
    }
    // if we're here c is part of the comment and therefore tossed
    if (isset($this->c)) {
        unset($this->c);
    }
    return $char;
}