From ba28c93eff52e25688a5fe4d8b7d022ad8be63e9 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Mon, 12 Oct 2020 17:21:17 +1000
Subject: [PATCH] Issue #3174022 by andypost, alexpott: call_user_func_array()
 and named arguments in PHP 8

---
 core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php       | 3 ++-
 .../src/FunctionalJavascript/SettingsTrayBlockFormTest.php     | 2 +-
 core/tests/Drupal/KernelTests/KernelTestBase.php               | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php b/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php
index 4548a0a52be8..5b37ea9bd44e 100644
--- a/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php
+++ b/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php
@@ -97,7 +97,8 @@ public function doTrustedCallback(callable $callback, array $args, $message, $er
       }
     }
 
-    return call_user_func_array($callback, $args);
+    // @TODO Allow named arguments in https://www.drupal.org/node/3174150
+    return call_user_func_array($callback, array_values($args));
   }
 
 }
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
index 2abcd36a0448..c5ade5da8bbe 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
@@ -49,7 +49,7 @@ protected function setUp(): void {
    */
   public function testBlocks() {
     foreach ($this->getBlockTests() as $test) {
-      call_user_func_array([$this, 'doTestBlocks'], $test);
+      call_user_func_array([$this, 'doTestBlocks'], array_values($test));
     }
   }
 
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index ba7c5712fa12..88c956b661b3 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -955,7 +955,7 @@ private static function getModulesToEnable($class) {
     // Modules have been collected in reverse class hierarchy order; modules
     // defined by base classes should be sorted first. Then, merge the results
     // together.
-    $modules = array_reverse($modules);
+    $modules = array_values(array_reverse($modules));
     return call_user_func_array('array_merge_recursive', $modules);
   }
 
-- 
GitLab