From 29befaa94b4960bf23b34b4126cc417d81347458 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 7 Apr 2021 09:56:15 -0400 Subject: [PATCH 1/3] Make ComposerRepository::configurePackageTransportOptions() protected. (#9818) --- src/Composer/Repository/ComposerRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index b4ec499d4..9959a326f 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -508,7 +508,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) { From cf69f3194a336a099fc03e0cd8bd997ad0dfd3e5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Apr 2021 13:22:48 +0200 Subject: [PATCH 2/3] Fix doctype annotations --- src/Composer/InstalledVersions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/InstalledVersions.php b/src/Composer/InstalledVersions.php index ecf517ad8..0747be367 100644 --- a/src/Composer/InstalledVersions.php +++ b/src/Composer/InstalledVersions.php @@ -202,7 +202,7 @@ class InstalledVersions * Returns the raw installed.php data for custom implementations * * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list} + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: array} */ public static function getRawData() { @@ -225,7 +225,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list} $data + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: array} $data */ public static function reload($data) { @@ -235,7 +235,7 @@ class InstalledVersions /** * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ private static function getInstalled() { From ddc3693725e9b202aa958ee1ab1b98cb95bc1b68 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Apr 2021 15:54:37 +0200 Subject: [PATCH 3/3] Switch to composer/metadata-minifier, fixes #9727 --- composer.json | 1 + composer.lock | 86 +++++++++++++++++-- .../Repository/ComposerRepository.php | 2 +- src/Composer/Util/MetadataMinifier.php | 68 ++------------- 4 files changed, 86 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index 981f96afe..0ee8df488 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 371202b49..2e1fdaced 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": "9b94ece2895724239b36aec399e5321a", + "content-hash": "983eaacb5443e19a04f1e119184b1e57", "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 9959a326f..5d238c713 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -33,7 +33,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; /** 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; - } }