From af18c2bd7d170095f194db185164aa8e526388a8 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 21 Apr 2020 14:50:11 +0200 Subject: [PATCH] Update semver, fix poolbuilder usage and optimize creation of filtering nameConstraints --- composer.lock | 151 ++++++++++++++++-- .../DependencyResolver/PoolBuilder.php | 19 ++- 2 files changed, 151 insertions(+), 19 deletions(-) diff --git a/composer.lock b/composer.lock index d0a3ab768..aa0f00386 100644 --- a/composer.lock +++ b/composer.lock @@ -60,6 +60,21 @@ "ssl", "tls" ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/ca-bundle/issues", + "source": "https://github.com/composer/ca-bundle/tree/1.2.7" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -68,19 +83,20 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "2fbee6b82f09aeaa3905444eb6652c554411fe55" + "reference": "03c921a6ef6ac36ca3aa0113a726e1b473f0f528" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/2fbee6b82f09aeaa3905444eb6652c554411fe55", - "reference": "2fbee6b82f09aeaa3905444eb6652c554411fe55", + "url": "https://api.github.com/repos/composer/semver/zipball/03c921a6ef6ac36ca3aa0113a726e1b473f0f528", + "reference": "03c921a6ef6ac36ca3aa0113a726e1b473f0f528", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5" + "phpstan/phpstan": "^0.12.19", + "phpunit/phpunit": "^4.5 || ^5.0.5 || ^7" }, "type": "library", "extra": { @@ -121,7 +137,12 @@ "validation", "versioning" ], - "time": "2020-04-16T13:02:51+00:00" + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/master" + }, + "time": "2020-04-21T12:22:29+00:00" }, { "name": "composer/spdx-licenses", @@ -181,6 +202,11 @@ "spdx", "validator" ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/spdx-licenses/issues", + "source": "https://github.com/composer/spdx-licenses/tree/1.5.3" + }, "time": "2020-02-14T07:44:31+00:00" }, { @@ -225,6 +251,17 @@ "Xdebug", "performance" ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/master" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + } + ], "time": "2020-03-01T12:26:26+00:00" }, { @@ -291,6 +328,10 @@ "json", "schema" ], + "support": { + "issues": "https://github.com/justinrainbow/json-schema/issues", + "source": "https://github.com/justinrainbow/json-schema/tree/5.2.9" + }, "time": "2019-09-25T14:49:45+00:00" }, { @@ -338,6 +379,9 @@ "psr", "psr-3" ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, "time": "2020-03-23T09:12:05+00:00" }, { @@ -375,12 +419,6 @@ "license": [ "MIT" ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], "description": "A lightweight implementation of CommonJS Promises/A for PHP", "time": "2016-03-07T13:46:50+00:00" }, @@ -431,6 +469,10 @@ "parser", "validator" ], + "support": { + "issues": "https://github.com/Seldaek/jsonlint/issues", + "source": "https://github.com/Seldaek/jsonlint/tree/1.7.2" + }, "time": "2019-10-24T14:27:39+00:00" }, { @@ -475,6 +517,10 @@ "keywords": [ "phar" ], + "support": { + "issues": "https://github.com/Seldaek/phar-utils/issues", + "source": "https://github.com/Seldaek/phar-utils/tree/1.1.0" + }, "time": "2020-02-14T15:25:33+00:00" }, { @@ -536,6 +582,9 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/console/tree/v2.8.52" + }, "time": "2018-11-20T15:55:20+00:00" }, { @@ -593,6 +642,9 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/debug/tree/v2.8.50" + }, "time": "2018-11-11T11:18:13+00:00" }, { @@ -643,6 +695,9 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v2.8.52" + }, "time": "2018-11-11T11:18:13+00:00" }, { @@ -692,6 +747,9 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v2.8.50" + }, "time": "2018-11-11T11:18:13+00:00" }, { @@ -750,6 +808,23 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.15.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -809,6 +884,23 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.15.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-09T19:04:49+00:00" }, { @@ -858,6 +950,9 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v2.8.50" + }, "time": "2018-11-11T11:18:13+00:00" } ], @@ -914,6 +1009,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/master" + }, "time": "2015-06-14T21:17:01+00:00" }, { @@ -963,6 +1062,10 @@ "email": "mike.vanriel@naenius.com" } ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/2.x" + }, "time": "2016-01-25T08:17:30+00:00" }, { @@ -1026,6 +1129,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" + }, "time": "2020-03-05T15:02:03+00:00" }, { @@ -1090,6 +1197,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/1.2" + }, "time": "2017-01-29T09:50:25+00:00" }, { @@ -1142,6 +1253,10 @@ "keywords": [ "diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/1.4" + }, "time": "2017-05-22T07:24:03+00:00" }, { @@ -1209,6 +1324,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/master" + }, "time": "2016-11-19T08:54:04+00:00" }, { @@ -1262,6 +1381,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" + }, "time": "2016-11-19T07:33:16+00:00" }, { @@ -1327,6 +1450,9 @@ ], "description": "Symfony PHPUnit Bridge", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/phpunit-bridge/tree/v3.4.38" + }, "time": "2020-02-21T08:01:47+00:00" } ], @@ -1343,5 +1469,6 @@ "platform-dev": [], "platform-overrides": { "php": "5.3.9" - } + }, + "plugin-api-version": "2.0.0" } diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index 44f7e2f45..f03a6bf24 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -122,7 +122,7 @@ class PoolBuilder } $loadNames[$packageName] = $constraint; - $this->nameConstraints[$packageName] = $constraint ? new MultiConstraint(array($constraint), false) : null; + $this->nameConstraints[$packageName] = $constraint && !($constraint instanceof EmptyConstraint) ? array($constraint) : null; } // clean up loadNames for anything we manually marked loaded above @@ -159,11 +159,17 @@ class PoolBuilder } // filter packages according to all the require statements collected for each package + $nameConstraints = array(); + foreach ($this->nameConstraints as $name => $constraints) { + if (is_array($constraints)) { + $nameConstraints[$name] = MultiConstraint::create(array_values(array_unique($constraints)), false); + } + } foreach ($this->packages as $i => $package) { // we check all alias related packages at once, so no need to check individual aliases // isset also checks non-null value - if (!$package instanceof AliasPackage && isset($this->nameConstraints[$package->getName()])) { - $constraint = $this->nameConstraints[$package->getName()]; + if (!$package instanceof AliasPackage && isset($nameConstraints[$package->getName()])) { + $constraint = $nameConstraints[$package->getName()]; $aliasedPackages = array($i => $package); if (isset($this->aliasMap[spl_object_hash($package)])) { @@ -270,10 +276,9 @@ class PoolBuilder $linkConstraint = $link->getConstraint(); if ($linkConstraint && !($linkConstraint instanceof EmptyConstraint)) { if (!array_key_exists($require, $this->nameConstraints)) { - $this->nameConstraints[$require] = new MultiConstraint(array($linkConstraint), false); - } elseif ($this->nameConstraints[$require]) { - // TODO addConstraint function? - $this->nameConstraints[$require] = new MultiConstraint(array_merge(array($linkConstraint), $this->nameConstraints[$require]->getConstraints()), false); + $this->nameConstraints[$require] = array($linkConstraint); + } elseif (is_array($this->nameConstraints[$require])) { + $this->nameConstraints[$require][] = $linkConstraint; } // else it is null and should stay null } else {