Skip to content

Commit

Permalink
Merge pull request #709 from mrclay/docker
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
mrclay authored Jan 4, 2024
2 parents 104ccd2 + 00e5e20 commit 4546378
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 80 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [4.0.0] - 2024-01-04

- Support PHP 8.1+
- Update PHPUnit to 8.x
- Replace `leafo/scssphp` with `scssphp/scssphp`

## [3.0.14] - 2023-05-05

- Support monolog v3, [#705]
Expand Down
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,36 @@
"wiki": "https://github.com/mrclay/minify/blob/master/docs"
},
"autoload": {
"classmap": ["lib/"]
"classmap": [
"lib/"
]
},
"autoload-dev": {
"psr-4": {"Minify\\Test\\": "tests/"}
"psr-4": {
"Minify\\Test\\": "tests/"
}
},
"config": {
"platform": {
"php": "5.3.29"
"php": "8.1.0"
},
"sort-packages": true
},
"require": {
"php": "^5.3.0 || ^7.0 || ^8.0",
"php": "^8.1",
"ext-pcre": "*",
"intervention/httpauth": "^2.0|^3.0",
"marcusschwarz/lesserphp": "^0.5.5",
"monolog/monolog": "~1.1|~2.0|~3.0",
"mrclay/jsmin-php": "~2",
"mrclay/props-dic": "^2.2|^3.0",
"mrclay/props-dic": "^4",
"tubalmartin/cssmin": "~4"
},
"require-dev": {
"firephp/firephp-core": "~0.4.0",
"leafo/scssphp": "^0.3 || ^0.6 || ^0.7",
"meenie/javascript-packer": "~1.1",
"phpunit/phpunit": "^4.8.36",
"phpunit/phpunit": "^8",
"scssphp/scssphp": "^1.12",
"tedivm/jshrink": "~1.1.0"
},
"suggest": {
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.7"
services:
apache:
image: php:8.3-apache
ports:
- 8080:80
volumes:
- .:/var/www/html/min
8 changes: 4 additions & 4 deletions lib/Minify/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function __construct($dir)

$type = $that->typeOf($ctrl);
throw new RuntimeException('$min_factories["controller"] callable must return an implementation'
." of Minify_CacheInterface. Returned $type");
. " of Minify_CacheInterface. Returned $type");
};

$this->docRoot = function (App $app) {
Expand Down Expand Up @@ -188,7 +188,7 @@ public function __construct($dir)

$type = $that->typeOf($value);
throw new RuntimeException('If set, $min_errorLogger must be a PSR-3 logger or a Monolog handler.'
." Given $type");
. " Given $type");
};

$this->minify = function (App $app) use ($that) {
Expand All @@ -205,7 +205,7 @@ public function __construct($dir)

$type = $that->typeOf($minify);
throw new RuntimeException('$min_factories["minify"] callable must return a Minify object.'
." Returned $type");
. " Returned $type");
};

$this->serveOptions = function (App $app) {
Expand All @@ -232,7 +232,7 @@ public function __construct($dir)
}

// check for URI versioning
if ($env->get('v') !== null || preg_match('/&\\d/', $app->env->server('QUERY_STRING'))) {
if ($env->get('v') !== null || preg_match('/&\\d/', $app->env->server('QUERY_STRING') ?? '')) {
$ret['maxAge'] = 31536000;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Minify/ClosureCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected function checkJar($jarFile)
*/
protected function checkTempdir($tempDir)
{
if (!is_dir($tempDir)) {
if ($tempDir === null || !is_dir($tempDir)) {
throw new Minify_ClosureCompiler_Exception('$tempDir(' . $tempDir . ') is not a valid direcotry.');
}
if (!is_writable($tempDir)) {
Expand Down
11 changes: 5 additions & 6 deletions lib/Minify/ScssCssSource.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Server;
use Leafo\ScssPhp\Version;
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\ScssPhp\Version;

/**
* Class for using SCSS files
Expand Down Expand Up @@ -152,12 +151,12 @@ private function compile($filename)
// and will treat the @import line as css import
$scss->setImportPaths(dirname($filename));

$css = $scss->compile(file_get_contents($filename), $filename);
$css = $scss->compileString(file_get_contents($filename), $filename)->getCss();
$elapsed = round((microtime(true) - $start), 4);

$v = Version::VERSION;
$ts = date('r', $start);
$css = "/* compiled by scssphp $v on $ts (${elapsed}s) */\n\n" . $css;
$ts = date('r', (int) $start);
$css = "/* compiled by scssphp $v on $ts ({$elapsed}s) */\n\n" . $css;

$imports = $scss->getParsedFiles();

Expand Down
50 changes: 26 additions & 24 deletions tests/HTTPEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ public function testZlibEncode()
);

foreach ($encodingTests as $test) {
$e = new HTTP_Encoder(array(
'content' => $variedContent,
'method' => $test['method'],
));
$e = new HTTP_Encoder(
array(
'content' => $variedContent,
'method' => $test['method'],
)
);
$e->encode(9);
$ret = $this->countBytes($e->getContent());

Expand Down Expand Up @@ -153,12 +155,12 @@ function _gzdecode($data)
}

// http://www.php.net/manual/en/function.gzdecode.php#82930
function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
function _phpman_gzdecode($data, &$filename = '', &$error = '', $maxlength = 0)
{
$mbIntEnc = null;
$hasMbOverload = (function_exists('mb_strlen')
&& (ini_get('mbstring.func_overload') !== '')
&& ((int)ini_get('mbstring.func_overload') & 2));
&& (ini_get('mbstring.func_overload') !== '')
&& ((int) ini_get('mbstring.func_overload') & 2));
if ($hasMbOverload) {
$mbIntEnc = mb_internal_encoding();
mb_internal_encoding('8bit');
Expand All @@ -174,7 +176,7 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
return null; // Not GZIP format (See RFC 1952)
}
$method = ord(substr($data, 2, 1)); // Compression method
$flags = ord(substr($data, 3, 1)); // Flags
$flags = ord(substr($data, 3, 1)); // Flags
if ($flags & 31 != $flags) {
$error = "Reserved bits not allowed.";
if ($mbIntEnc !== null) {
Expand All @@ -185,11 +187,11 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
// NOTE: $mtime may be negative (PHP integer limitations)
$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 = "";
$extralen = 0;
$extra = "";
if ($flags & 4) {
// 2-byte length prefixed EXTRA data in header
if ($len - $headerlen - 2 < 8) {
Expand Down Expand Up @@ -276,7 +278,7 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
$isize = unpack("V", substr($data, -4));
$isize = $isize[1];
// decompression:
$bodylen = $len-$headerlen-8;
$bodylen = $len - $headerlen - 8;
if ($bodylen < 1) {
// IMPLEMENTATION BUG!
if ($mbIntEnc !== null) {
Expand All @@ -288,20 +290,20 @@ function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
$data = "";
if ($bodylen > 0) {
switch ($method) {
case 8:
// Currently the only supported compression method:
$data = gzinflate($body, $maxlength);
break;
default:
$error = "Unknown compression method.";
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return false;
case 8:
// Currently the only supported compression method:
$data = gzinflate($body, $maxlength);
break;
default:
$error = "Unknown compression method.";
if ($mbIntEnc !== null) {
mb_internal_encoding($mbIntEnc);
}
return false;
}
} // 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) {
Expand Down
4 changes: 3 additions & 1 deletion tests/LessSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

class LessSourceTest extends TestCase
{
public function setUp()
public string $realDocRoot;

public function setUp(): void
{
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCSSUriRewriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MinifyCSSUriRewriterTest extends TestCase
{
public function setUp()
public function setUp(): void
{
Minify_CSS_UriRewriter::$debugText = '';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCacheAPCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MinifyCacheAPCTest extends TestCase
{
public function setUp()
public function setUp(): void
{
if (!function_exists('apc_store')) {
$this->markTestSkipped("To test this component, install APC extension");
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCacheAPCuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MinifyCacheAPCuTest extends TestCase
{
public function setUp()
public function setUp(): void
{
if (!function_exists('apcu_store')) {
$this->markTestSkipped("To test this component, install APCu extension");
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCacheMemcacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MinifyCacheMemcacheTest extends TestCase
/** @var Memcache */
private $mc;

public function setUp()
public function setUp(): void
{
if (!function_exists('memcache_set')) {
$this->markTestSkipped("To test this component, install memcache in PHP");
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCacheWinCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MinifyCacheWinCacheTest extends TestCase
{
public function setUp()
public function setUp(): void
{
if (!function_exists('wincache_ucache_info')) {
$this->markTestSkipped("To test this component, install WinCache extension");
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyCacheZendPlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MinifyCacheZendPlatformTest extends TestCase
{
public function setUp()
public function setUp(): void
{
if (!function_exists('output_cache_put')) {
// FIXME: be specific what to actually install
Expand Down
2 changes: 1 addition & 1 deletion tests/MinifyClosureCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MinifyClosureCompilerTest extends TestCase
{
public static function setupBeforeClass()
public static function setupBeforeClass(): void
{
parent::setupBeforeClass();
Minify_ClosureCompiler::$isDebug = true;
Expand Down
Loading

0 comments on commit 4546378

Please sign in to comment.