1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-30 17:19:54 +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:
Elan Ruusamäe
2020-04-03 10:43:07 +03:00
parent 031e804d08
commit b31855f6b8
50 changed files with 217 additions and 188 deletions

View File

@@ -166,15 +166,15 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
$len = strlen($data);
if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) {
if ($len < 18 || strcmp(substr($data, 0, 2), "\x1f\x8b")) {
$error = "Not in GZIP format.";
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return null; // Not GZIP format (See RFC 1952)
}
$method = ord(substr($data,2,1)); // Compression method
$flags = ord(substr($data,3,1)); // Flags
$method = ord(substr($data, 2, 1)); // Compression method
$flags = ord(substr($data, 3, 1)); // Flags
if ($flags & 31 != $flags) {
$error = "Reserved bits not allowed.";
if ($mbIntEnc !== null) {
@@ -183,10 +183,10 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
return null;
}
// NOTE: $mtime may be negative (PHP integer limitations)
$mtime = unpack("V", substr($data,4,4));
$mtime = unpack("V", substr($data, 4, 4));
$mtime = $mtime[1];
$xfl = substr($data,8,1);
$os = substr($data,8,1);
$xfl = substr($data, 8, 1);
$os = substr($data, 8, 1);
$headerlen = 10;
$extralen = 0;
$extra = "";
@@ -198,7 +198,7 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return false; // invalid
}
$extralen = unpack("v",substr($data,8,2));
$extralen = unpack("v", substr($data, 8, 2));
$extralen = $extralen[1];
if ($len - $headerlen - 2 - $extralen < 8) {
if ($mbIntEnc !== null) {
@@ -206,7 +206,7 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return false; // invalid
}
$extra = substr($data,10,$extralen);
$extra = substr($data, 10, $extralen);
$headerlen += 2 + $extralen;
}
$filenamelen = 0;
@@ -219,14 +219,14 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return false; // invalid
}
$filenamelen = strpos(substr($data,$headerlen),chr(0));
$filenamelen = strpos(substr($data, $headerlen), chr(0));
if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return false; // invalid
}
$filename = substr($data,$headerlen,$filenamelen);
$filename = substr($data, $headerlen, $filenamelen);
$headerlen += $filenamelen + 1;
}
$commentlen = 0;
@@ -239,14 +239,14 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return false; // invalid
}
$commentlen = strpos(substr($data,$headerlen),chr(0));
$commentlen = strpos(substr($data, $headerlen), chr(0));
if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return false; // Invalid header format
}
$comment = substr($data,$headerlen,$commentlen);
$comment = substr($data, $headerlen, $commentlen);
$headerlen += $commentlen + 1;
}
$headercrc = "";
@@ -258,8 +258,8 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return false; // invalid
}
$calccrc = crc32(substr($data,0,$headerlen)) & 0xffff;
$headercrc = unpack("v", substr($data,$headerlen,2));
$calccrc = crc32(substr($data, 0, $headerlen)) & 0xffff;
$headercrc = unpack("v", substr($data, $headerlen, 2));
$headercrc = $headercrc[1];
if ($headercrc != $calccrc) {
$error = "Header checksum failed.";
@@ -271,9 +271,9 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
$headerlen += 2;
}
// GZIP FOOTER
$datacrc = unpack("V",substr($data,-8,4));
$datacrc = sprintf('%u',$datacrc[1] & 0xFFFFFFFF);
$isize = unpack("V",substr($data,-4));
$datacrc = unpack("V", substr($data, -8, 4));
$datacrc = sprintf('%u', $datacrc[1] & 0xFFFFFFFF);
$isize = unpack("V", substr($data, -4));
$isize = $isize[1];
// decompression:
$bodylen = $len-$headerlen-8;
@@ -284,13 +284,13 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
return null;
}
$body = substr($data,$headerlen,$bodylen);
$body = substr($data, $headerlen, $bodylen);
$data = "";
if ($bodylen > 0) {
switch ($method) {
case 8:
// Currently the only supported compression method:
$data = gzinflate($body,$maxlength);
$data = gzinflate($body, $maxlength);
break;
default:
$error = "Unknown compression method.";
@@ -301,11 +301,11 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
}
} // zero-byte body content is allowed
// Verifiy CRC32
$crc = sprintf("%u",crc32($data));
$crc = sprintf("%u", crc32($data));
$crcOK = $crc == $datacrc;
$lenOK = $isize == strlen($data);
if (!$lenOK || !$crcOK) {
$error = ( $lenOK ? '' : 'Length check FAILED. ') . ( $crcOK ? '' : 'Checksum FAILED.');
$error = ($lenOK ? '' : 'Length check FAILED. ') . ($crcOK ? '' : 'Checksum FAILED.');
$ret = false;
}
$ret = $data;
@@ -313,4 +313,4 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
mb_internal_encoding($mbIntEnc);
}
return $ret;
}
}

View File

@@ -126,4 +126,4 @@ class JSMinTest extends TestCase
),
);
}
}
}

View File

@@ -32,8 +32,11 @@ class JsClosureCompilerTest extends TestCase
$this->compile($src);
} catch (Minify_JS_ClosureCompiler_Exception $e) {
}
$this->assertInstanceOf('Minify_JS_ClosureCompiler_Exception', $e,
'Throws Minify_JS_ClosureCompiler_Exception');
$this->assertInstanceOf(
'Minify_JS_ClosureCompiler_Exception',
$e,
'Throws Minify_JS_ClosureCompiler_Exception'
);
}
// Test maximum byte size check (default)
@@ -46,8 +49,11 @@ class JsClosureCompilerTest extends TestCase
$this->compile($src);
} catch (Minify_JS_ClosureCompiler_Exception $e) {
}
$this->assertInstanceOf('Minify_JS_ClosureCompiler_Exception', $e,
'Throws Minify_JS_ClosureCompiler_Exception');
$this->assertInstanceOf(
'Minify_JS_ClosureCompiler_Exception',
$e,
'Throws Minify_JS_ClosureCompiler_Exception'
);
$expected = 'POST content larger than ' . Minify_JS_ClosureCompiler::DEFAULT_MAX_BYTES . ' bytes';
$this->assertEquals($expected, $e->getMessage(), 'Message must tell how big maximum byte size is');
@@ -76,8 +82,11 @@ class JsClosureCompilerTest extends TestCase
));
} catch (Minify_JS_ClosureCompiler_Exception $e) {
}
$this->assertInstanceOf('Minify_JS_ClosureCompiler_Exception', $e,
'Throws Minify_JS_ClosureCompiler_Exception');
$this->assertInstanceOf(
'Minify_JS_ClosureCompiler_Exception',
$e,
'Throws Minify_JS_ClosureCompiler_Exception'
);
$expected = 'POST content larger than ' . $allowedBytes . ' bytes';
$this->assertEquals($expected, $e->getMessage(), 'Message must tell how big maximum byte size is');
@@ -96,8 +105,11 @@ class JsClosureCompilerTest extends TestCase
));
} catch (Minify_JS_ClosureCompiler_Exception $e) {
}
$this->assertInstanceOf('Minify_JS_ClosureCompiler_Exception', $e,
'Throws Minify_JS_ClosureCompiler_Exception');
$this->assertInstanceOf(
'Minify_JS_ClosureCompiler_Exception',
$e,
'Throws Minify_JS_ClosureCompiler_Exception'
);
}
public function test7()

View File

@@ -39,4 +39,4 @@ class LessSourceTest extends TestCase
$this->assertEquals("/min/g=less&amp;{$max}", $res);
}
}
}

View File

@@ -25,4 +25,4 @@ class MinifyBuildTest extends TestCase
$this->assertEquals($b->uri('/path'), "/path?{$maxTime}", 'uri() with no querystring');
$this->assertEquals($b->uri('/path?hello'), "/path?hello&amp;{$maxTime}", 'uri() with existing querystring');
}
}
}

View File

@@ -16,9 +16,10 @@ class MinifyCSSUriRewriterTest extends TestCase
$in = file_get_contents(self::$test_files . '/css_uriRewriter/in.css');
$expected = file_get_contents(self::$test_files . '/css_uriRewriter/exp.css');
$actual = Minify_CSS_UriRewriter::rewrite(
$in
, self::$test_files . '/css_uriRewriter' // currentDir
, self::$document_root // use DOCUMENT_ROOT = '/full/path/to/min_unit_tests'
$in,
self::$test_files . '/css_uriRewriter' // currentDir
,
self::$document_root // use DOCUMENT_ROOT = '/full/path/to/min_unit_tests'
);
$this->assertEquals($expected, $actual, 'rewrite, debug: ' . Minify_CSS_UriRewriter::$debugText);
@@ -47,9 +48,9 @@ class MinifyCSSUriRewriterTest extends TestCase
$in = '../../../../assets/skins/sam/sprite.png';
$exp = '/yui/assets/skins/sam/sprite.png';
$actual = Minify_CSS_UriRewriter::rewriteRelative(
$in
, 'sf_root_dir\web\yui\menu\assets\skins\sam'
, 'sf_root_dir\web'
$in,
'sf_root_dir\web\yui\menu\assets\skins\sam',
'sf_root_dir\web'
);
$this->assertEquals($exp, $actual, 'Issue 99, debug: ' . Minify_CSS_UriRewriter::$debugText);

View File

@@ -22,4 +22,4 @@ class MinifyCacheAPCTest extends TestCase
$cache = new Minify_Cache_APC();
$this->assertTestCache($cache, $id, $data);
}
}
}

View File

@@ -45,4 +45,3 @@ class MinifyCacheMemcacheTest extends TestCase
$this->assertTestCache($cache, $id, $data);
}
}

View File

@@ -21,4 +21,4 @@ class MinifyCacheWinCacheTest extends TestCase
$cache = new Minify_Cache_WinCache();
$this->assertTestCache($cache, $id, $data);
}
}
}

View File

@@ -22,4 +22,4 @@ class MinifyCacheZendPlatformTest extends TestCase
$cache = new Minify_Cache_ZendPlatform();
$this->assertTestCache($cache, $id, $data);
}
}
}

View File

@@ -31,4 +31,4 @@ class MinifyCommentPreserverTest extends TestCase
++$callCount;
return $callCount . strtoupper($content);
}
}
}

View File

@@ -80,4 +80,4 @@ class MinifyHTMLHelperTest extends TestCase
$this->assertEquals($maxTime, $output, 'utils.php : Minify_mtime w/ obj & group');
}
}
}
}

View File

@@ -23,7 +23,10 @@ class MinifyImportProcessorTest extends TestCase
realpath($linDir . '/lib/css/example.css'),
);
$this->assertEquals($expectedIncludes, Minify_ImportProcessor::$filesIncluded,
'included right files in right order');
$this->assertEquals(
$expectedIncludes,
Minify_ImportProcessor::$filesIncluded,
'included right files in right order'
);
}
}

View File

@@ -54,4 +54,4 @@ class MinifyNailgunClosureCompilerTest extends TestCase
$this->markTestSkipped($e->getMessage());
}
}
}
}

View File

@@ -62,8 +62,8 @@ class MinifyTest extends TestCase
$content = preg_replace('/\\r\\n?/', "\n", file_get_contents($minifyTestPath . '/minified.js'));
$lastModified = max(
filemtime($minifyTestPath . '/email.js')
, filemtime($minifyTestPath . '/QueryString.js')
filemtime($minifyTestPath . '/email.js'),
filemtime($minifyTestPath . '/QueryString.js')
);
$expected = array(
'success' => true,
@@ -153,8 +153,10 @@ class MinifyTest extends TestCase
));
$output = $output['content'];
$this->assertFalse(strpos($output, $defaultOptions['importWarning']),
'Issue 89 : don\'t warn about valid imports');
$this->assertFalse(
strpos($output, $defaultOptions['importWarning']),
'Issue 89 : don\'t warn about valid imports'
);
// Test Issue 132
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
@@ -164,8 +166,11 @@ class MinifyTest extends TestCase
'encodeOutput' => false,
));
$this->assertEquals(77, $output['headers']['Content-Length'],
'Issue 132 : mbstring.func_overload shouldn\'t cause incorrect Content-Length');
$this->assertEquals(
77,
$output['headers']['Content-Length'],
'Issue 132 : mbstring.func_overload shouldn\'t cause incorrect Content-Length'
);
}
// Test minifying CSS and responding with Etag/Last-Modified

View File

@@ -60,4 +60,4 @@ class MinifyYuiCSSTest extends TestCase
$this->markTestSkipped($e->getMessage());
}
}
}
}

View File

@@ -39,4 +39,4 @@ class ScssSourceTest extends TestCase
$this->assertEquals("/min/g=scss&amp;{$max}", $res);
}
}
}

View File

@@ -70,4 +70,4 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
return $contents;
}
}
}