diff --git a/composer.json b/composer.json index 3dc1a2165..6e2c31bfa 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "require": { "php": "^5.3.2 || ^7.0 || ^8.0", "composer/ca-bundle": "^1.0", + "composer/metadata-minifier": "^1.0", "composer/semver": "^3.0", "composer/spdx-licenses": "^1.2", "composer/xdebug-handler": "^1.1", diff --git a/composer.lock b/composer.lock index 8acac0375..b2cdb5b23 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": "25f0d90eaaae2900e23844f74e662e82", + "content-hash": "5275194a1c51ef2f95f92838cc728abc", "packages": [ { "name": "composer/ca-bundle", @@ -82,6 +82,75 @@ ], "time": "2021-01-12T12:10:35+00:00" }, + { + "name": "composer/metadata-minifier", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/metadata-minifier.git", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207", + "reference": "c549d23829536f0d0e984aaabbf02af91f443207", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2", + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\MetadataMinifier\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Small utility library that handles metadata minification and expansion.", + "keywords": [ + "composer", + "compression" + ], + "support": { + "issues": "https://github.com/composer/metadata-minifier/issues", + "source": "https://github.com/composer/metadata-minifier/tree/1.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2021-04-07T13:37:33+00:00" + }, { "name": "composer/semver", "version": "3.2.4", @@ -244,16 +313,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.5", + "version": "1.4.6", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f28d44c286812c714741478d968104c5e604a1d4" + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4", - "reference": "f28d44c286812c714741478d968104c5e604a1d4", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", "shasum": "" }, "require": { @@ -261,7 +330,8 @@ "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "autoload": { @@ -287,7 +357,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.5" + "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" }, "funding": [ { @@ -303,7 +373,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T08:04:11+00:00" + "time": "2021-03-25T17:01:18+00:00" }, { "name": "justinrainbow/json-schema", diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 49e0e5b90..308972309 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -35,7 +35,7 @@ use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Util\Http\Response; -use Composer\Util\MetadataMinifier; +use Composer\MetadataMinifier\MetadataMinifier; use Composer\Util\Url; /** @@ -510,7 +510,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito return array(); } - private function configurePackageTransportOptions(PackageInterface $package) + protected function configurePackageTransportOptions(PackageInterface $package) { foreach ($package->getDistUrls() as $url) { if (strpos($url, $this->baseUrl) === 0) { diff --git a/src/Composer/Util/MetadataMinifier.php b/src/Composer/Util/MetadataMinifier.php index ba4cc0a93..6fae871c3 100644 --- a/src/Composer/Util/MetadataMinifier.php +++ b/src/Composer/Util/MetadataMinifier.php @@ -12,67 +12,11 @@ namespace Composer\Util; -class MetadataMinifier +@trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED); + +/** + * @deprecated Use Composer\MetadataMinifier\MetadataMinifier instead + */ +class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier { - public static function expand(array $versions) - { - $expanded = array(); - $expandedVersion = null; - foreach ($versions as $versionData) { - if (!$expandedVersion) { - $expandedVersion = $versionData; - $expanded[] = $expandedVersion; - continue; - } - - // add any changes from the previous version to the expanded one - foreach ($versionData as $key => $val) { - if ($val === '__unset') { - unset($expandedVersion[$key]); - } else { - $expandedVersion[$key] = $val; - } - } - - $expanded[] = $expandedVersion; - } - - return $expanded; - } - - public static function minify(array $versions) - { - $minifiedVersions = array(); - - $lastKnownVersionData = null; - foreach ($versions as $version) { - if (!$lastKnownVersionData) { - $lastKnownVersionData = $version; - $minifiedVersions[] = $version; - continue; - } - - $minifiedVersion = array(); - - // add any changes from the previous version - foreach ($version as $key => $val) { - if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) { - $minifiedVersion[$key] = $val; - $lastKnownVersionData[$key] = $val; - } - } - - // store any deletions from the previous version for keys missing in current one - foreach ($lastKnownVersionData as $key => $val) { - if (!isset($version[$key])) { - $minifiedVersion[$key] = "__unset"; - unset($lastKnownVersionData[$key]); - } - } - - $minifiedVersions[] = $minifiedVersion; - } - - return $minifiedVersions; - } }