Browse Source

Add composer-runtime-api version constant

Alessandro Lai 4 years ago
parent
commit
ff05150c4e
2 changed files with 18 additions and 0 deletions
  1. 11 0
      src/Composer/Composer.php
  2. 7 0
      src/Composer/Repository/PlatformRepository.php

+ 11 - 0
src/Composer/Composer.php

@@ -55,6 +55,17 @@ class Composer
     const RELEASE_DATE = '@release_date@';
     const SOURCE_VERSION = '1.10-dev+source';
 
+    /**
+     * Version number of the internal composer-runtime-api package
+     *
+     * This is used to version features available to projects at runtime
+     * like the platform-check file, the Composer\InstalledVersions class
+     * and possibly others in the future.
+     *
+     * @var string
+     */
+    const RUNTIME_API_VERSION = '1.0.0';
+
     public static function getVersion()
     {
         // no replacement done, this must be a source checkout

+ 7 - 0
src/Composer/Repository/PlatformRepository.php

@@ -12,6 +12,7 @@
 
 namespace Composer\Repository;
 
+use Composer\Composer;
 use Composer\Package\CompletePackage;
 use Composer\Package\PackageInterface;
 use Composer\Package\Version\VersionParser;
@@ -74,6 +75,12 @@ class PlatformRepository extends ArrayRepository
         $composerPluginApi->setDescription('The Composer Plugin API');
         $this->addPackage($composerPluginApi);
 
+        $prettyVersion = Composer::RUNTIME_API_VERSION;
+        $version = $this->versionParser->normalize($prettyVersion);
+        $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
+        $composerRuntimeApi->setDescription('The Composer Runtime API');
+        $this->addPackage($composerRuntimeApi);
+
         try {
             $prettyVersion = PHP_VERSION;
             $version = $this->versionParser->normalize($prettyVersion);