1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-22 13:42:48 +02:00

Apply php-cs-fixer new rules

This commit is contained in:
Elan Ruusamäe
2019-12-11 17:00:16 +02:00
parent f9d3d54e62
commit eff278193b
88 changed files with 1225 additions and 1213 deletions

View File

@@ -1,18 +1,13 @@
<?php
/**
* Class Minify_CommentPreserver
* @package Minify
*/
/**
* Process a string in pieces preserving C-style comments that begin with "/*!"
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
class Minify_CommentPreserver
{
/**
* String to be prepended to each preserved comment
*
@@ -38,6 +33,7 @@ class Minify_CommentPreserver
* @param callback $processor function
* @param array $args array of extra arguments to pass to the processor
* function (default = array())
*
* @return string
*/
public static function process($content, $processor, $args = array())
@@ -45,12 +41,12 @@ class Minify_CommentPreserver
$ret = '';
while (true) {
list($beforeComment, $comment, $afterComment) = self::_nextComment($content);
if ('' !== $beforeComment) {
if ($beforeComment !== '') {
$callArgs = $args;
array_unshift($callArgs, $beforeComment);
$ret .= call_user_func_array($processor, $callArgs);
}
if (false === $comment) {
if ($comment === false) {
break;
}
$ret .= $comment;
@@ -72,7 +68,7 @@ class Minify_CommentPreserver
*/
private static function _nextComment($in)
{
if (false === ($start = strpos($in, '/*!')) || false === ($end = strpos($in, '*/', $start + 3))) {
if (($start = strpos($in, '/*!')) === false || ($end = strpos($in, '*/', $start + 3)) === false) {
return array($in, false, false);
}
@@ -80,7 +76,7 @@ class Minify_CommentPreserver
$comment = self::$prepend . '/*!' . substr($in, $start + 3, $end - $start - 1) . self::$append;
$endChars = (strlen($in) - $end - 2);
$afterComment = (0 === $endChars) ? '' : substr($in, -$endChars);
$afterComment = ($endChars === 0) ? '' : substr($in, -$endChars);
return array($beforeComment, $comment, $afterComment);
}