1
0
Fork 0

Switch to composer/metadata-minifier, fixes #9727

pull/9828/head
Jordi Boggiano 2021-04-07 15:54:37 +02:00
parent cf69f3194a
commit ddc3693725
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
4 changed files with 86 additions and 71 deletions

View File

@ -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",

86
composer.lock generated
View File

@ -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",

View File

@ -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;
/**

View File

@ -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;
}
}