From 588c41138220b880a8db22684a0d05fec0982178 Mon Sep 17 00:00:00 2001 From: Kim Brown <50059399+kbrown9@users.noreply.github.com> Date: Mon, 25 May 2020 13:07:52 -0400 Subject: [PATCH] Autoloader: Support Composer v2.0 Add support for Composer 2.0: - Allow version ^2.0 of the composer-plugin-api package. - Implement the PluginInterface::deactivate() and PluginInterface::uninstall() methods. Code cleanup: - Fix a typo. --- packages/autoloader/composer.json | 2 +- .../autoloader/src/CustomAutoloaderPlugin.php | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/autoloader/composer.json b/packages/autoloader/composer.json index 82ea34b09f8a1..5d510a158694a 100644 --- a/packages/autoloader/composer.json +++ b/packages/autoloader/composer.json @@ -4,7 +4,7 @@ "type": "composer-plugin", "license": "GPL-2.0-or-later", "require": { - "composer-plugin-api": "^1.1" + "composer-plugin-api": "^1.1 || ^2.0" }, "require-dev": { "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5" diff --git a/packages/autoloader/src/CustomAutoloaderPlugin.php b/packages/autoloader/src/CustomAutoloaderPlugin.php index 189e891e9623b..35c7dd737b6af 100644 --- a/packages/autoloader/src/CustomAutoloaderPlugin.php +++ b/packages/autoloader/src/CustomAutoloaderPlugin.php @@ -53,10 +53,39 @@ public function activate( Composer $composer, IOInterface $io ) { // phpcs:ignor $this->io = $io; } + /** + * Do nothing. + * phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + * + * @param Composer $composer Composer object. + * @param IOInterface $io IO object. + */ + public function deactivate( Composer $composer, IOInterface $io ) { + /* + * Intentionally left empty. This is a PluginInterface method. + * phpcs:enable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + */ + } + + /** + * Do nothing. + * phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + * + * @param Composer $composer Composer object. + * @param IOInterface $io IO object. + */ + public function uninstall( Composer $composer, IOInterface $io ) { + /* + * Intentionally left empty. This is a PluginInterface method. + * phpcs:enable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + */ + } + + /** * Tell composer to listen for events and do something with them. * - * @return array List of succribed events. + * @return array List of subscribed events. */ public static function getSubscribedEvents() { return array(