8000 Allow providers which are selected to be installed in place of existing packages which do not satisfy requirements by Seldaek · Pull Request #8561 · composer/composer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow providers which are selected to be installed in place of existing packages which do not satisfy requirements #8561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions src/Composer/DependencyResolver/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
class Pool implements \Countable
{
const MATCH_NAME = -1;
const MATCH_NONE = 0;
const MATCH = 1;
const MATCH_PROVIDE = 2;
Expand Down Expand Up @@ -117,27 +116,15 @@ private function computeWhatProvides($name, $constraint, $mustMatchName = false)
$candidates = $this->packageByName[$name];
}

$matches = $provideMatches = array();
$nameMatch = false;
$matches = array();

foreach ($candidates as $candidate) {
switch ($this->match($candidate, $name, $constraint)) {
case self::MATCH_NONE:
break;

case self::MATCH_NAME:
$nameMatch = true;
break;

case self::MATCH:
$nameMatch = true;
$matches[] = $candidate;
break;

case self::MATCH_PROVIDE:
$provideMatches[] = $candidate;
break;

case self::MATCH_REPLACE:
$matches[] = $candidate;
break;
Expand All @@ -147,12 +134,7 @@ private function computeWhatProvides($name, $constraint, $mustMatchName = false)
}
}

// if a package with the required name exists, we ignore providers
if ($nameMatch) {
return $matches;
}

return array_merge($matches, $provideMatches);
return $matches;
}

public function literalToPackage($literal)
Expand Down Expand Up @@ -196,7 +178,7 @@ public function match($candidate, $name, ConstraintInterface $constraint = null)
return self::MATCH;
}

return self::MATCH_NAME;
return self::MATCH_NONE;
}

$provides = $candidate->getProvides();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Test that providers can be installed if they are selected and the package they provide is not installable
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{
"name": "foo/polyfill",
"provide": {
"foo/standard": "1.0.0"
},
"version": "1.0.0"
},
{
"name": "foo/standard",
"require": {
"foo/does-not-exist": "1.0.0"
},
"version": "1.0.0"
}
]
}
],
"require": {
"foo/standard": "1.0.0",
"foo/polyfill": "1.0.0"
}
}

--RUN--
update

--EXPECT--
Installing foo/polyfill (1.0.0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
Test that providers can be installed in conjunction with the package they provide if they are selected and the package they provide is also installable
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{
"name": "foo/polyfill",
"provide": {
"foo/standard": "1.0.0"
},
"version": "1.0.0"
},
{
"name": "foo/standard",
"version": "1.0.0"
}
]
}
],
"require": {
"foo/standard": "1.0.0",
"foo/polyfill": "1.0.0"
}
}

--RUN--
update

--EXPECT--
Installing foo/standard (1.0.0)
Installing foo/polyfill (1.0.0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
Test that providers can not be installed if they are not selected
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{
"name": "foo/polyfill",
"provide": {
"foo/standard": "1.0.0"
},
"version": "1.0.0"
},
{
"name": "foo/standard",
"require": {
"foo/does-not-exist": "1.0.0"
},
"version": "1.0.0"
}
]
}
],
"require": {
"foo/standard": "1.0.0"
}
}

--RUN--
update

--EXPECT-EXIT-CODE--
2

--EXPECT-OUTPUT--
Loading compose 5F7C r repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Root composer.json requires foo/standard 1.0.0 -> satisfiable by foo/standard[1.0.0].
- foo/standard 1.0.0 requires foo/does-not-exist 1.0.0 -> no matching package found.

Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

--EXPECT--

0