diff --git a/composer.json b/composer.json index 2bd532acc..36dbfe22d 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "composer/ca-bundle": "^1.0", "composer/class-map-generator": "^1.0", "composer/metadata-minifier": "^1.0", - "composer/semver": "^3.0", + "composer/semver": "^3.2.5", "composer/spdx-licenses": "^1.5.7", "composer/xdebug-handler": "^2.0.2 || ^3.0.3", "justinrainbow/json-schema": "^5.2.11", diff --git a/composer.lock b/composer.lock index 760cdabff..e43a5d2cb 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": "cc535e8c9fc8f1414a1cede463898453", + "content-hash": "c50c89580fa044b7523cb55c2d557c87", "packages": [ { "name": "composer/ca-bundle", diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 5dfeb18c8..21b76ec3a 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -557,6 +557,19 @@ class Problem */ protected static function constraintToText(?ConstraintInterface $constraint = null): string { + if ($constraint instanceof Constraint && $constraint->getOperator() === Constraint::STR_OP_EQ && !str_starts_with($constraint->getVersion(), 'dev-')) { + if (!Preg::isMatch('{^\d+(?:\.\d+)*$}', $constraint->getPrettyString())) { + return ' '.$constraint->getPrettyString() .' (exact version match)'; + } + + $versions = [$constraint->getPrettyString()]; + for ($i = 3 - substr_count($versions[0], '.'); $i > 0; $i--) { + $versions[] = end($versions) . '.0'; + } + + return ' ' . $constraint->getPrettyString() . ' (exact version match: ' . (count($versions) > 1 ? implode(', ', array_slice($versions, 0, -1)) . ' or ' . end($versions) : $versions[0]) . ')'; + } + return $constraint ? ' '.$constraint->getPrettyString() : ''; } } diff --git a/tests/Composer/Test/Fixtures/installer/alias-on-unloadable-package.test b/tests/Composer/Test/Fixtures/installer/alias-on-unloadable-package.test index 58cd7d818..0f9f2c5ef 100644 --- a/tests/Composer/Test/Fixtures/installer/alias-on-unloadable-package.test +++ b/tests/Composer/Test/Fixtures/installer/alias-on-unloadable-package.test @@ -24,7 +24,6 @@ Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - - Root composer.json requires a/aliased 3.0.2 as 3.0.3, found a/aliased[1.2.3] but it does not match the constraint. + - Root composer.json requires a/aliased 3.0.2 as 3.0.3 (exact version match), found a/aliased[1.2.3] but it does not match the constraint. --EXPECT-- - diff --git a/tests/Composer/Test/Fixtures/installer/solver-problems-with-disabled-platform.test b/tests/Composer/Test/Fixtures/installer/solver-problems-with-disabled-platform.test index 2c698a2a6..2cf503056 100644 --- a/tests/Composer/Test/Fixtures/installer/solver-problems-with-disabled-platform.test +++ b/tests/Composer/Test/Fixtures/installer/solver-problems-with-disabled-platform.test @@ -59,7 +59,7 @@ Your requirements could not be resolved to an installable set of packages. Problem 3 - Root composer.json requires linked library lib-icu 1001.* but it has the wrong version installed, try upgrading the intl extension. Problem 4 - - Root composer.json requires PHP extension ext-foobar 1.0.0 but it is missing from your system. Install or enable PHP's foobar extension. + - Root composer.json requires PHP extension ext-foobar 1.0.0 (exact version match: 1.0.0 or 1.0.0.0) but it is missing from your system. Install or enable PHP's foobar extension. Problem 5 - Root composer.json requires PHP extension ext-pcre ^8 but the ext-pcre package is disabled by your platform config. Enable it again with "composer config platform.ext-pcre --unset". Problem 6 diff --git a/tests/Composer/Test/Fixtures/installer/solver-problems.test b/tests/Composer/Test/Fixtures/installer/solver-problems.test index 6b9c03630..610911bb9 100644 --- a/tests/Composer/Test/Fixtures/installer/solver-problems.test +++ b/tests/Composer/Test/Fixtures/installer/solver-problems.test @@ -113,7 +113,7 @@ Your requirements could not be resolved to an installable set of packages. Problem 3 - Root composer.json requires non-existent/pkg, it could not be found in any version, there may be a typo in the package name. Problem 4 - - Root composer.json requires stable-requiree-excluded/pkg 1.0.1, found stable-requiree-excluded/pkg[1.0.1] but the package is fixed to 1.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. + - Root composer.json requires stable-requiree-excluded/pkg 1.0.1 (exact version match: 1.0.1 or 1.0.1.0), found stable-requiree-excluded/pkg[1.0.1] but the package is fixed to 1.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. Problem 5 - Root composer.json requires linked library lib-xml 1002.* but it has the wrong version installed or is missing from your system, make sure to load the extension providing it. Problem 6 @@ -121,7 +121,7 @@ Your requirements could not be resolved to an installable set of packages. Problem 7 - Root composer.json requires PHP extension ext-xml 1002.* but it has the wrong version installed (%s). Problem 8 - - Root composer.json requires php 1 but your php version (%s) does not satisfy that requirement. + - Root composer.json requires php 1 (exact version match: 1, 1.0, 1.0.0 or 1.0.0.0) but your php version (%s) does not satisfy that requirement. Problem 9 - Root composer.json requires package/found 2.* -> satisfiable by package/found[2.0.0]. - package/found 2.0.0 requires unstable/package2 2.* -> found unstable/package2[2.0.0-alpha] but it does not match your minimum-stability.