Add support for Composer v2
In Composer v2, packages are solved first (dev and non-dev), then the lock file is written, then packages (dev and/or non-dev) are installed/updated/removed. As such, the closest alternative to the retired PRE_DEPENDENCIES_SOLVING is the new PRE_POOL_CREATE (and not PRE_OPERATIONS_EXEC as has been attempted in various plugins).
The use of PRE_DEPENDENCIES_SOLVING in the merge-plugin is used to inject duplicate requirements (usually with a different version constraints) into the solver (while distinguishing between require and require-dev).
To support Composer v1 and v2 without overcomplicating things, this commit replaces duplicate link tracking in ExtraPackage by back porting Composer 2's new static MultiConstraint::create() method which can be used to resolve complex-constraints early on. In turn, this makes the need for PRE_DEPENDENCIES_SOLVING obsolete.
- Allow either ^1.1 or ^2.0 composer-plugin-api
- New PluginInterface methods
- New MultiConstraint back port from Composer v2 for v1
- Replaced PluginState::$duplicateLinks with MultiConstraint to merge requirements and constraints in ExtraPackage::mergeOrDefer() instead of during PRE_DEPENDENCIES_SOLVING
- Locking condition on POST_PACKAGE_INSTALL to force update in Composer v2
- Testing of POST_PACKAGE_INSTALL to reflect forced update in Composer v2
- Mocking of VcsRepository to support HttpDownloader for Composer v2
- Event PRE_DEPENDENCIES_SOLVING and method MergePlugin::onDependencySolve() since ExtraPackage::mergeOrDefer() handles duplicate package constraints
- Mocked event PRE_DEPENDENCIES_SOLVING in MergePluginTest::triggerPlugin() since duplicates are no longer tracked
- Assertions for obsolete $extraInstalls from MergePluginTest::triggerPlugin()