mirror of
https://github.com/composer/composer
synced 2025-05-11 01:22:54 +00:00
Refactor based on code review
- Move the version api getter to the PluginManager And make it such that it can be mocked, but not pollute the public interface. That means "protected" visibility. - The plugin api version constant should still be used throughout the code. - Use different fixtures class names - Use regex possessive quantifiers for performance - Use full words for readability
This commit is contained in:
parent
eb2aa14830
commit
3032f0a538
12 changed files with 33 additions and 61 deletions
|
@ -130,10 +130,11 @@ class PluginManager
|
|||
throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
|
||||
}
|
||||
|
||||
$currPluginApiVersion = $this->composer->getConfig()->getPluginApiVersion();
|
||||
$currPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currPluginApiVersion));
|
||||
if (!$requiresComposer->matches($currPluginApiConstraint)) {
|
||||
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
||||
$currentPluginApiVersion = $this->getPluginApiVersion();
|
||||
$currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));
|
||||
|
||||
if (!$requiresComposer->matches($currentPluginApiConstraint)) {
|
||||
$this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -276,4 +277,14 @@ class PluginManager
|
|||
|
||||
return $this->globalComposer->getInstallationManager()->getInstallPath($package);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the internal composer-plugin-api package.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPluginApiVersion()
|
||||
{
|
||||
return PluginInterface::PLUGIN_API_VERSION;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue