From 2c757bac860490a1959f5dba511fc0295918c978 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Sun, 22 Nov 2020 21:21:19 +0000
Subject: [PATCH] Issue #3098281 by greg.1.anderson, alexpott, heddn, Mile23,
 xjm, jungle, longwave: Ensure that 'composer update' evaluates dependencies
 using the correct PHP version

---
 composer.json                                     |  5 ++++-
 composer.lock                                     |  9 ++++++---
 core/composer.json                                |  2 +-
 core/tests/Drupal/Tests/Composer/ComposerTest.php | 13 +++++++++++++
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/composer.json b/composer.json
index 72285e32c21b..12508828a1f8 100644
--- a/composer.json
+++ b/composer.json
@@ -46,7 +46,10 @@
     "prefer-stable": true,
     "config": {
         "preferred-install": "dist",
-        "autoloader-suffix": "Drupal9"
+        "autoloader-suffix": "Drupal9",
+        "platform": {
+            "php": "7.3.0"
+        }
     },
     "extra": {
         "_readme": [
diff --git a/composer.lock b/composer.lock
index d8243e6a026d..45c05a39c3af 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "460aef4d3073d9f5e8e6a2dae54468d6",
+    "content-hash": "54a8c91f9d19473abf71ea242e3138d9",
     "packages": [
         {
             "name": "asm89/stack-cors",
@@ -528,7 +528,7 @@
             "dist": {
                 "type": "path",
                 "url": "core",
-                "reference": "af5b9453adf15c6831b1f73e322f8c59da877f14"
+                "reference": "4659974dafc65cf2e9fbe00c8be0ccd0ef0aadba"
             },
             "require": {
                 "asm89/stack-cors": "^1.1",
@@ -554,7 +554,7 @@
                 "laminas/laminas-feed": "^2.12",
                 "masterminds/html5": "^2.1",
                 "pear/archive_tar": "^1.4.9",
-                "php": ">=7.3",
+                "php": ">=7.3.0",
                 "psr/log": "^1.0",
                 "stack/builder": "^1.0",
                 "symfony-cmf/routing": "^2.1",
@@ -7699,5 +7699,8 @@
     "prefer-lowest": false,
     "platform": [],
     "platform-dev": [],
+    "platform-overrides": {
+        "php": "7.3.0"
+    },
     "plugin-api-version": "2.0.0"
 }
diff --git a/core/composer.json b/core/composer.json
index 671a37e8d662..eea29f6acf30 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -17,7 +17,7 @@
         "ext-SPL": "*",
         "ext-tokenizer": "*",
         "ext-xml": "*",
-        "php": ">=7.3",
+        "php": ">=7.3.0",
         "symfony/console": "^4.4",
         "symfony/dependency-injection": "^4.4",
         "symfony/event-dispatcher": "^4.4",
diff --git a/core/tests/Drupal/Tests/Composer/ComposerTest.php b/core/tests/Drupal/Tests/Composer/ComposerTest.php
index 2e1d1bdfaba5..0eb4e227cdba 100644
--- a/core/tests/Drupal/Tests/Composer/ComposerTest.php
+++ b/core/tests/Drupal/Tests/Composer/ComposerTest.php
@@ -25,4 +25,17 @@ public function testEnsureComposerVersion() {
     }
   }
 
+  /**
+   * Ensure that the configured php version matches the minimum php version.
+   *
+   * Also ensure that the minimum php version in the root-level composer.json
+   * file exactly matches DRUPAL_MINIMUM_PHP.
+   */
+  public function testEnsurePhpConfiguredVersion() {
+    $composer_json = json_decode(file_get_contents($this->root . '/composer.json'), TRUE);
+    $composer_core_json = json_decode(file_get_contents($this->root . '/core/composer.json'), TRUE);
+    $this->assertEquals(DRUPAL_MINIMUM_PHP, $composer_json['config']['platform']['php'], 'The DRUPAL_MINIMUM_PHP constant should always be exactly the same as the config.platform.php in the root composer.json.');
+    $this->assertEquals($composer_core_json['require']['php'], '>=' . $composer_json['config']['platform']['php'], 'The config.platform.php configured version in the root composer.json file should always be exactly the same as the minimum php version configured in core/composer.json.');
+  }
+
 }
-- 
GitLab