Same name in other branches
- 5.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::processMultiLineComments()
- 6.0.x advagg_js_minify/jshrink.inc \JShrink\Minifier::processMultiLineComments()
- 7.x-2.x advagg_js_compress/jshrink.inc \JShrink\Minifier::processMultiLineComments()
- 8.x-3.x advagg_js_minify/jshrink.inc \JShrink\Minifier::processMultiLineComments()
- 8.x-4.x advagg_js_minify/jshrink.inc \JShrink\Minifier::processMultiLineComments()
Skips multiline comments where appropriate, and includes them where needed. Conditional comments and "license" style blocks are preserved.
Parameters
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 in 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.
File
-
advagg_js_minify/
jshrink.inc, line 401
Class
- Minifier
- Minifier
Namespace
JShrinkCode
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;
}