mirror of
https://github.com/mrclay/minify.git
synced 2025-09-02 18:32:58 +02:00
Apply php-cs-fixer fixers
- braces - function_declaration - lowercase_keywords - method_argument_space - no_spaces_inside_parenthesis - no_trailing_whitespace - no_trailing_whitespace_in_comment - single_blank_line_at_eof
This commit is contained in:
@@ -204,9 +204,10 @@ class HTTP_Encoder
|
||||
}
|
||||
// gzip checks (slow)
|
||||
if (preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
'@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@',
|
||||
$ae,
|
||||
$m
|
||||
)) {
|
||||
return array('gzip', $m[1]);
|
||||
}
|
||||
if ($allowDeflate) {
|
||||
@@ -217,14 +218,17 @@ class HTTP_Encoder
|
||||
|| 0 === strpos($ae, 'deflate,') // opera
|
||||
// slow parsing
|
||||
|| preg_match(
|
||||
'@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
|
||||
'@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@',
|
||||
$ae
|
||||
)) {
|
||||
return array('deflate', 'deflate');
|
||||
}
|
||||
}
|
||||
if ($allowCompress && preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
'@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@',
|
||||
$ae,
|
||||
$m
|
||||
)) {
|
||||
return array('compress', $m[1]);
|
||||
}
|
||||
|
||||
|
@@ -242,7 +242,7 @@ class Minify
|
||||
if (! $this->options['quiet']) {
|
||||
$this->errorExit($this->options['badRequestHeader'], self::URL_DEBUG);
|
||||
} else {
|
||||
list(,$statusCode) = explode(' ', $this->options['badRequestHeader']);
|
||||
list(, $statusCode) = explode(' ', $this->options['badRequestHeader']);
|
||||
|
||||
return array(
|
||||
'success' => false,
|
||||
@@ -470,7 +470,7 @@ class Minify
|
||||
public function errorExit($header, $url = '', $msgHtml = '')
|
||||
{
|
||||
$url = htmlspecialchars($url, ENT_QUOTES);
|
||||
list(,$h1) = explode(' ', $header, 2);
|
||||
list(, $h1) = explode(' ', $header, 2);
|
||||
$h1 = htmlspecialchars($h1);
|
||||
// FastCGI environments require 3rd arg to header() to be set
|
||||
list(, $code) = explode(' ', $header, 3);
|
||||
@@ -593,7 +593,8 @@ class Minify
|
||||
! $source // yes, we ran out of sources
|
||||
|| $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits)
|
||||
|| $minifier !== $lastMinifier // yes, minifier changed
|
||||
|| $options !== $lastOptions)) { // yes, options changed
|
||||
|| $options !== $lastOptions // yes, options changed
|
||||
)) {
|
||||
// minify previous sources with last settings
|
||||
$imploded = implode($implodeSeparator, $groupToProcessTogether);
|
||||
$groupToProcessTogether = array();
|
||||
|
@@ -82,8 +82,7 @@ class App extends Container
|
||||
|
||||
$varDefined = get_defined_vars();
|
||||
|
||||
$varNames = array_filter($varNames, function($name) use($varDefined)
|
||||
{
|
||||
$varNames = array_filter($varNames, function ($name) use ($varDefined) {
|
||||
return array_key_exists($name, $varDefined);
|
||||
});
|
||||
|
||||
|
@@ -73,16 +73,16 @@ class Minify_CSSmin
|
||||
}
|
||||
if ($options['currentDir']) {
|
||||
return Minify_CSS_UriRewriter::rewrite(
|
||||
$css
|
||||
,$options['currentDir']
|
||||
,$options['docRoot']
|
||||
,$options['symlinks']
|
||||
$css,
|
||||
$options['currentDir'],
|
||||
$options['docRoot'],
|
||||
$options['symlinks']
|
||||
);
|
||||
}
|
||||
|
||||
return Minify_CSS_UriRewriter::prepend(
|
||||
$css
|
||||
,$options['prependRelativePath']
|
||||
$css,
|
||||
$options['prependRelativePath']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -64,4 +64,4 @@ class Minify_Cache_Null implements Minify_CacheInterface
|
||||
public function fetch($id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -136,4 +136,4 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,4 +68,3 @@ class Minify_Controller_Files extends Minify_Controller_Base
|
||||
return new Minify_ServeConfiguration($options, $sources);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -73,4 +73,3 @@ class Minify_Controller_Groups extends Minify_Controller_Files
|
||||
return parent::createConfiguration($options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -66,4 +66,3 @@ class Minify_Controller_Page extends Minify_Controller_Base
|
||||
return new Minify_ServeConfiguration($options, $sources, $selectionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,4 +19,4 @@ interface Minify_ControllerInterface
|
||||
* @return Minify_Env
|
||||
*/
|
||||
public function getEnv();
|
||||
}
|
||||
}
|
||||
|
@@ -99,32 +99,34 @@ class Minify_HTML
|
||||
|
||||
// replace SCRIPTs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/(\\s*)<script(\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/iu'
|
||||
,array($this, '_removeScriptCB')
|
||||
,$this->_html);
|
||||
'/(\\s*)<script(\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/iu',
|
||||
array($this, '_removeScriptCB'),
|
||||
$this->_html
|
||||
);
|
||||
|
||||
// replace STYLEs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*<style(\\b[^>]*>)([\\s\\S]*?)<\\/style>\\s*/iu'
|
||||
,array($this, '_removeStyleCB')
|
||||
,$this->_html);
|
||||
'/\\s*<style(\\b[^>]*>)([\\s\\S]*?)<\\/style>\\s*/iu',
|
||||
array($this, '_removeStyleCB'),
|
||||
$this->_html
|
||||
);
|
||||
|
||||
// remove HTML comments (not containing IE conditional comments).
|
||||
$this->_html = preg_replace_callback(
|
||||
'/<!--([\\s\\S]*?)-->/u'
|
||||
,array($this, '_commentCB')
|
||||
,$this->_html);
|
||||
'/<!--([\\s\\S]*?)-->/u',
|
||||
array($this, '_commentCB'),
|
||||
$this->_html
|
||||
);
|
||||
|
||||
// replace PREs with placeholders
|
||||
$this->_html = preg_replace_callback('/\\s*<pre(\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/iu'
|
||||
,array($this, '_removePreCB')
|
||||
,$this->_html);
|
||||
$this->_html = preg_replace_callback('/\\s*<pre(\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/iu', array($this, '_removePreCB'), $this->_html);
|
||||
|
||||
// replace TEXTAREAs with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*<textarea(\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/iu'
|
||||
,array($this, '_removeTextareaCB')
|
||||
,$this->_html);
|
||||
'/\\s*<textarea(\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/iu',
|
||||
array($this, '_removeTextareaCB'),
|
||||
$this->_html
|
||||
);
|
||||
|
||||
// trim each line.
|
||||
// @todo take into account attribute values that span multiple lines.
|
||||
@@ -139,24 +141,25 @@ class Minify_HTML
|
||||
|
||||
// remove ws outside of all elements
|
||||
$this->_html = preg_replace(
|
||||
'/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?</u'
|
||||
,'>$1$2$3<'
|
||||
,$this->_html);
|
||||
'/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?</u',
|
||||
'>$1$2$3<',
|
||||
$this->_html
|
||||
);
|
||||
|
||||
// use newlines before 1st attribute in open tags (to limit line lengths)
|
||||
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/iu', "$1\n$2", $this->_html);
|
||||
|
||||
// fill placeholders
|
||||
$this->_html = str_replace(
|
||||
array_keys($this->_placeholders)
|
||||
,array_values($this->_placeholders)
|
||||
,$this->_html
|
||||
array_keys($this->_placeholders),
|
||||
array_values($this->_placeholders),
|
||||
$this->_html
|
||||
);
|
||||
// issue 229: multi-pass to catch scripts that didn't get replaced in textareas
|
||||
$this->_html = str_replace(
|
||||
array_keys($this->_placeholders)
|
||||
,array_values($this->_placeholders)
|
||||
,$this->_html
|
||||
array_keys($this->_placeholders),
|
||||
array_values($this->_placeholders),
|
||||
$this->_html
|
||||
);
|
||||
|
||||
return $this->_html;
|
||||
@@ -209,7 +212,8 @@ class Minify_HTML
|
||||
: 'trim';
|
||||
$css = call_user_func($minifier, $css);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($css)
|
||||
return $this->_reservePlace(
|
||||
$this->_needsCdata($css)
|
||||
? "{$openStyle}/*<![CDATA[*/{$css}/*]]>*/</style>"
|
||||
: "{$openStyle}{$css}</style>"
|
||||
);
|
||||
@@ -238,7 +242,8 @@ class Minify_HTML
|
||||
: 'trim';
|
||||
$js = call_user_func($minifier, $js);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($js)
|
||||
return $this->_reservePlace(
|
||||
$this->_needsCdata($js)
|
||||
? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
|
||||
: "{$ws1}{$openScript}{$js}</script>{$ws2}"
|
||||
);
|
||||
|
@@ -66,7 +66,7 @@ class Minify_ImportProcessor
|
||||
$this->_currentDir = dirname($file);
|
||||
|
||||
// remove UTF-8 BOM if present
|
||||
if (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3)) {
|
||||
if (pack("CCC", 0xef, 0xbb, 0xbf) === substr($content, 0, 3)) {
|
||||
$content = substr($content, 3);
|
||||
}
|
||||
// ensure uniform EOLs
|
||||
|
@@ -195,13 +195,13 @@ class Minify_JS_ClosureCompiler
|
||||
curl_close($ch);
|
||||
} else {
|
||||
throw new Minify_JS_ClosureCompiler_Exception(
|
||||
"Could not make HTTP request: allow_url_open is false and cURL not available"
|
||||
"Could not make HTTP request: allow_url_open is false and cURL not available"
|
||||
);
|
||||
}
|
||||
|
||||
if (false === $contents) {
|
||||
throw new Minify_JS_ClosureCompiler_Exception(
|
||||
"No HTTP response from server"
|
||||
"No HTTP response from server"
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -110,4 +110,4 @@ class Minify_NailgunClosureCompiler extends Minify_ClosureCompiler
|
||||
|
||||
$this->shell("$serverCommand </dev/null >/dev/null 2>/dev/null & sleep 10");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -170,7 +170,7 @@ class Minify_Source_Factory
|
||||
if ($this->options['noMinPattern'] && preg_match($this->options['noMinPattern'], $basename)) {
|
||||
if (preg_match('~\.(css|less)$~i', $basename)) {
|
||||
$spec['minifyOptions']['compress'] = false;
|
||||
// we still want URI rewriting to work for CSS
|
||||
// we still want URI rewriting to work for CSS
|
||||
} else {
|
||||
$spec['minifier'] = 'Minify::nullMinifier';
|
||||
}
|
||||
|
@@ -154,4 +154,3 @@ class Minify_YUICompressor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -390,4 +390,3 @@ class Cli
|
||||
$this->errors[$letter][] = sprintf($msg, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user