diff --git a/src/Composer/Config.php b/src/Composer/Config.php
index 4d0ac5858..ba8e2bdc7 100644
--- a/src/Composer/Config.php
+++ b/src/Composer/Config.php
@@ -341,14 +341,4 @@ class Config
return false;
}
-
- /**
- * Returns the version of the internal composer-plugin-api package.
- *
- * @return string
- */
- public function getPluginApiVersion()
- {
- return PluginInterface::PLUGIN_API_VERSION;
- }
}
diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php
index 6a3ec65bb..a9b78d64d 100644
--- a/src/Composer/Package/Version/VersionParser.php
+++ b/src/Composer/Package/Version/VersionParser.php
@@ -246,7 +246,7 @@ class VersionParser
private function isOldStylePluginApiVersion($requiredPluginApiVersion)
{
// catch "1.0", "1.0.0", "1.0.0.0" etc.
- return (bool) preg_match('#^1(\.0)+$#', trim($requiredPluginApiVersion));
+ return (bool) preg_match('#^1(\.0)++$#', trim($requiredPluginApiVersion));
}
/**
diff --git a/src/Composer/Plugin/PluginInterface.php b/src/Composer/Plugin/PluginInterface.php
index 34fc0957a..dea5828c1 100644
--- a/src/Composer/Plugin/PluginInterface.php
+++ b/src/Composer/Plugin/PluginInterface.php
@@ -26,7 +26,6 @@ interface PluginInterface
* Version number of the fake composer-plugin-api package
*
* @var string
- * @deprecated Use \Composer\Config::getPluginApiVersion() instead.
*/
const PLUGIN_API_VERSION = '1.0.0';
diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php
index 29bdd2e52..a7d91d5b3 100644
--- a/src/Composer/Plugin/PluginManager.php
+++ b/src/Composer/Plugin/PluginManager.php
@@ -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('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.');
+ $currentPluginApiVersion = $this->getPluginApiVersion();
+ $currentPluginApiConstraint = new VersionConstraint('==', $this->versionParser->normalize($currentPluginApiVersion));
+
+ if (!$requiresComposer->matches($currentPluginApiConstraint)) {
+ $this->io->writeError('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.');
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;
+ }
}
diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php
index 976cd5d04..7ef11786b 100644
--- a/src/Composer/Repository/PlatformRepository.php
+++ b/src/Composer/Repository/PlatformRepository.php
@@ -34,11 +34,6 @@ class PlatformRepository extends ArrayRepository
*/
private $overrides;
- /**
- * @var Config
- */
- private $config;
-
public function __construct(array $packages = array(), array $overrides = array())
{
parent::__construct($packages);
@@ -68,7 +63,7 @@ class PlatformRepository extends ArrayRepository
parent::addPackage($package);
}
- $prettyVersion = $this->getConfig()->getPluginApiVersion();
+ $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
$version = $versionParser->normalize($prettyVersion);
$composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
$composerPluginApi->setDescription('The Composer Plugin API');
@@ -216,23 +211,4 @@ class PlatformRepository extends ArrayRepository
{
return 'ext-' . str_replace(' ', '-', $name);
}
-
- /**
- * @param Config $config
- */
- public function setConfig(Config $config)
- {
- $this->config = $config;
- }
-
- /**
- * @return Config
- */
- public function getConfig()
- {
- if (!$this->config) {
- $this->config = new Config;
- }
- return $this->config;
- }
}
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin.php b/tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin5.php
similarity index 83%
rename from tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin.php
rename to tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin5.php
index 2dae1b48b..a2ac37bc5 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin.php
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v5/Installer/Plugin5.php
@@ -6,7 +6,7 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
-class Plugin implements PluginInterface
+class Plugin5 implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v5/composer.json b/tests/Composer/Test/Plugin/Fixtures/plugin-v5/composer.json
index e52970367..7885cd6fd 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v5/composer.json
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v5/composer.json
@@ -4,7 +4,7 @@
"type": "composer-plugin",
"autoload": { "psr-0": { "Installer": "" } },
"extra": {
- "class": "Installer\\Plugin"
+ "class": "Installer\\Plugin5"
},
"require": {
"composer-plugin-api": "*"
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin.php b/tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin6.php
similarity index 83%
rename from tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin.php
rename to tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin6.php
index 2dae1b48b..e46c0fcb0 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin.php
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v6/Installer/Plugin6.php
@@ -6,7 +6,7 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
-class Plugin implements PluginInterface
+class Plugin6 implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v6/composer.json b/tests/Composer/Test/Plugin/Fixtures/plugin-v6/composer.json
index ca8108021..b620edee0 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v6/composer.json
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v6/composer.json
@@ -1,10 +1,10 @@
{
- "name": "plugin-v5",
+ "name": "plugin-v6",
"version": "1.0.0",
"type": "composer-plugin",
"autoload": { "psr-0": { "Installer": "" } },
"extra": {
- "class": "Installer\\Plugin"
+ "class": "Installer\\Plugin6"
},
"require": {
"composer-plugin-api": "~1.2"
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin.php b/tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin7.php
similarity index 83%
rename from tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin.php
rename to tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin7.php
index 2dae1b48b..5560a6047 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin.php
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v7/Installer/Plugin7.php
@@ -6,7 +6,7 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
-class Plugin implements PluginInterface
+class Plugin7 implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
diff --git a/tests/Composer/Test/Plugin/Fixtures/plugin-v7/composer.json b/tests/Composer/Test/Plugin/Fixtures/plugin-v7/composer.json
index c03fca1c8..ee8627cb1 100644
--- a/tests/Composer/Test/Plugin/Fixtures/plugin-v7/composer.json
+++ b/tests/Composer/Test/Plugin/Fixtures/plugin-v7/composer.json
@@ -1,10 +1,10 @@
{
- "name": "plugin-v5",
+ "name": "plugin-v7",
"version": "1.0.0",
"type": "composer-plugin",
"autoload": { "psr-0": { "Installer": "" } },
"extra": {
- "class": "Installer\\Plugin"
+ "class": "Installer\\Plugin7"
},
"require": {
"composer-plugin-api": ">=3.0.0 <5.5"
diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php
index ba45bad0b..8bebe7d28 100644
--- a/tests/Composer/Test/Plugin/PluginInstallerTest.php
+++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php
@@ -222,19 +222,15 @@ class PluginInstallerTest extends TestCase
private function setPluginApiVersionWithPlugins($newPluginApiVersion, array $plugins = array())
{
// reset the plugin manager's installed plugins
- $this->pm = new PluginManager($this->io, $this->composer);
+ $this->pm = $this->getMockBuilder('Composer\Plugin\PluginManager')
+ ->setMethods(array('getPluginApiVersion'))
+ ->setConstructorArgs(array($this->io, $this->composer))
+ ->getMock();
- /** @var \PHPUnit_Framework_MockObject_MockObject $config */
- $config = $this->getMock('Composer\Config', array('getPluginApiVersion'));
-
- // mock Config to return whatever Plugin API version we wish
- $config->expects($this->any())
- ->method('getPluginApiVersion')
- ->will($this->returnValue($newPluginApiVersion));
-
- // transfer the defaults in our Config mock and set it
- $config->merge($this->composer->getConfig()->raw());
- $this->composer->setConfig($config);
+ // mock the Plugin API version
+ $this->pm->expects($this->any())
+ ->method('getPluginApiVersion')
+ ->will($this->returnValue($newPluginApiVersion));
$plugApiInternalPackage = $this->getPackage(
'composer-plugin-api',