diff --git a/composer.json b/composer.json index 2a23ad0ff3db2..1433e7240dd51 100644 --- a/composer.json +++ b/composer.json @@ -41,14 +41,13 @@ "colinmollenhour/credis": "^1.15", "colinmollenhour/php-redis-session-abstract": "^2.0", "composer/composer": "^2.0, !=2.2.16", - "elasticsearch/elasticsearch": "^8.15", "duosecurity/duo_api_php": "^1.1", "duosecurity/duo_universal_php": "^1.0", + "elasticsearch/elasticsearch": "^8.15", "ezyang/htmlpurifier": "^4.17", "guzzlehttp/guzzle": "^7.5", "laminas/laminas-captcha": "^2.18", "laminas/laminas-code": "^4.13", - "magento/magento-zf-db": "^3.21", "laminas/laminas-di": "^3.15", "laminas/laminas-escaper": "^2.13", "laminas/laminas-eventmanager": "^3.11", @@ -69,9 +68,11 @@ "magento/composer": "^1.10.1-beta1", "magento/composer-dependency-version-audit-plugin": "^0.1", "magento/magento-composer-installer": ">=0.4.0", + "magento/magento-zf-db": "^3.21", "magento/zend-cache": "^1.16", "magento/zend-db": "^1.16", "magento/zend-pdf": "^1.16", + "matthiasmullie/minify": "^1.3", "monolog/monolog": "^3.6", "opensearch-project/opensearch-php": "^2.3", "pelago/emogrifier": "^7.0", @@ -82,12 +83,10 @@ "ramsey/uuid": "^4.2", "symfony/console": "^6.4", "symfony/intl": "^6.4", - "symfony/process": "^6.4", - "symfony/string": "^6.4", "symfony/mailer": "^6.4", "symfony/mime": "^6.4", - "tedivm/jshrink": "^1.4", - "tubalmartin/cssmin": "^4.1", + "symfony/process": "^6.4", + "symfony/string": "^6.4", "web-token/jwt-framework": "^3.4", "webonyx/graphql-php": "^15.0", "wikimedia/less.php": "^5.0" diff --git a/composer.lock b/composer.lock index 7b20c8ffa539b..00e452f515eae 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c0a82fa4155cf2880ee2593885bab2ac", + "content-hash": "e606f3740e13d5b3b480254aec6cffc2", "packages": [ { "name": "aws/aws-crt-php", @@ -4789,6 +4789,129 @@ }, "time": "2024-12-18T14:59:28+00:00" }, + { + "name": "matthiasmullie/minify", + "version": "1.3.75", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/minify.git", + "reference": "76ba4a5f555fd7bf4aa408af608e991569076671" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/76ba4a5f555fd7bf4aa408af608e991569076671", + "reference": "76ba4a5f555fd7bf4aa408af608e991569076671", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "matthiasmullie/path-converter": "~1.1", + "php": ">=5.3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": ">=2.0", + "matthiasmullie/scrapbook": ">=1.3", + "phpunit/phpunit": ">=4.8" + }, + "suggest": { + "psr/cache-implementation": "Cache implementation to use with Minify::cache" + }, + "bin": [ + "bin/minifycss", + "bin/minifyjs" + ], + "type": "library", + "autoload": { + "psr-4": { + "MatthiasMullie\\Minify\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "minify@mullie.eu", + "homepage": "https://www.mullie.eu", + "role": "Developer" + } + ], + "description": "CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.", + "homepage": "https://github.com/matthiasmullie/minify", + "keywords": [ + "JS", + "css", + "javascript", + "minifier", + "minify" + ], + "support": { + "issues": "https://github.com/matthiasmullie/minify/issues", + "source": "https://github.com/matthiasmullie/minify/tree/1.3.75" + }, + "funding": [ + { + "url": "https://github.com/matthiasmullie", + "type": "github" + } + ], + "time": "2025-06-25T09:56:19+00:00" + }, + { + "name": "matthiasmullie/path-converter", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/path-converter.git", + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9", + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "MatthiasMullie\\PathConverter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "pathconverter@mullie.eu", + "homepage": "http://www.mullie.eu", + "role": "Developer" + } + ], + "description": "Relative path converter", + "homepage": "http://github.com/matthiasmullie/path-converter", + "keywords": [ + "converter", + "path", + "paths", + "relative" + ], + "support": { + "issues": "https://github.com/matthiasmullie/path-converter/issues", + "source": "https://github.com/matthiasmullie/path-converter/tree/1.1.3" + }, + "time": "2019-02-05T23:41:09+00:00" + }, { "name": "monolog/monolog", "version": "3.8.1", @@ -9693,123 +9816,6 @@ ], "time": "2025-01-07T12:55:42+00:00" }, - { - "name": "tedivm/jshrink", - "version": "v1.7.0", - "source": { - "type": "git", - "url": "https://github.com/tedious/JShrink.git", - "reference": "7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tedious/JShrink/zipball/7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e", - "reference": "7a35f5a4651ca2ce77295eb8a3b4e133ba47e19e", - "shasum": "" - }, - "require": { - "php": "^7.0|^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.14", - "php-coveralls/php-coveralls": "^2.5.0", - "phpunit/phpunit": "^9|^10" - }, - "type": "library", - "autoload": { - "psr-0": { - "JShrink": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Robert Hafner", - "email": "tedivm@tedivm.com" - } - ], - "description": "Javascript Minifier built in PHP", - "homepage": "http://github.com/tedious/JShrink", - "keywords": [ - "javascript", - "minifier" - ], - "support": { - "issues": "https://github.com/tedious/JShrink/issues", - "source": "https://github.com/tedious/JShrink/tree/v1.7.0" - }, - "funding": [ - { - "url": "https://github.com/tedivm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/tedivm/jshrink", - "type": "tidelift" - } - ], - "time": "2023-10-04T17:23:23+00:00" - }, - { - "name": "tubalmartin/cssmin", - "version": "v4.1.1", - "source": { - "type": "git", - "url": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port.git", - "reference": "3cbf557f4079d83a06f9c3ff9b957c022d7805cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tubalmartin/YUI-CSS-compressor-PHP-port/zipball/3cbf557f4079d83a06f9c3ff9b957c022d7805cf", - "reference": "3cbf557f4079d83a06f9c3ff9b957c022d7805cf", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "php": ">=5.3.2" - }, - "require-dev": { - "cogpowered/finediff": "0.3.*", - "phpunit/phpunit": "4.8.*" - }, - "bin": [ - "cssmin" - ], - "type": "library", - "autoload": { - "psr-4": { - "tubalmartin\\CssMin\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Túbal Martín", - "homepage": "http://tubalmartin.me/" - } - ], - "description": "A PHP port of the YUI CSS compressor", - "homepage": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port", - "keywords": [ - "compress", - "compressor", - "css", - "cssmin", - "minify", - "yui" - ], - "support": { - "issues": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues", - "source": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port" - }, - "time": "2018-01-15T15:26:51+00:00" - }, { "name": "web-token/jwt-framework", "version": "3.4.7", @@ -14716,5 +14722,5 @@ "lib-libxml": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php b/lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php index dc4f554ba2949..9a22800ad41e0 100644 --- a/lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php +++ b/lib/internal/Magento/Framework/Code/Minifier/Adapter/Css/CSSmin.php @@ -5,58 +5,24 @@ */ namespace Magento\Framework\Code\Minifier\Adapter\Css; -use tubalmartin\CssMin\Minifier as CssMinLibrary; use Magento\Framework\Code\Minifier\AdapterInterface; +use MatthiasMullie\Minify\CSS; /** * Adapter for CSSmin library */ class CSSmin implements AdapterInterface { - /** - * 'pcre.recursion_limit' value for CSSMin minification - */ - const PCRE_RECURSION_LIMIT = 1000; - - /** - * @var CssMinLibrary - */ - protected $cssMinifier; - - /** - * @param CssMinLibrary $cssMinifier - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function __construct(CssMinLibrary $cssMinifier) - { - // TODO: set $cssMinifier in constructor once MAGETWO-51176 is resolved. - } - - /** - * Get CSS Minifier - * - * @return CssMinLibrary - */ - private function getCssMin() - { - if (!($this->cssMinifier instanceof CssMinLibrary)) { - $this->cssMinifier = new CssMinLibrary(false); - } - return $this->cssMinifier; - } - /** * Minify css file content * * @param string $content * @return string */ - public function minify($content) + public function minify($content): string { - $pcreRecursionLimit = ini_get('pcre.recursion_limit'); - ini_set('pcre.recursion_limit', self::PCRE_RECURSION_LIMIT); - $result = $this->getCssMin()->run($content); - ini_set('pcre.recursion_limit', $pcreRecursionLimit); - return $result; + $cssMinifier = new CSS(); + + return $cssMinifier->add($content)->minify(); } } diff --git a/lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php b/lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php index 456fcd7d35a7e..5cd7eba694d48 100644 --- a/lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php +++ b/lib/internal/Magento/Framework/Code/Minifier/Adapter/Js/JShrink.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Code\Minifier\Adapter\Js; -use JShrink\Minifier; +use MatthiasMullie\Minify; use Magento\Framework\Code\Minifier\AdapterInterface; /** @@ -15,15 +15,17 @@ class JShrink implements AdapterInterface { /** - * Takes a string containing javascript and removes unneeded characters in - * order to shrink the code without altering it's functionality. + * Takes a string containing JavaScript and removes unneeded characters + * to shrink the code without altering its functionality. * - * @param string $content The raw javascript to be minified + * @param string $content The raw JavaScript to be minified * @throws \Exception * @return bool|string */ - public function minify($content) + public function minify($content): bool|string { - return Minifier::minify($content); + $minifier = new Minify\JS(); + + return $minifier->add($content)->minify(); } }