From 11ddd4c06c32fa957aa3b3d5c572a4712d163f58 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Wed, 24 Jun 2020 10:07:36 +1000
Subject: [PATCH] Issue #2904467 by quietone, andyg5000: Plugins do not
 preserve integer keys when parsing annotations

(cherry picked from commit d22493e774441e4c3fbb8095d46c41d326ae03cd)
---
 core/lib/Drupal/Component/Annotation/Plugin.php             | 2 +-
 core/tests/Drupal/Tests/Component/Annotation/PluginTest.php | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Component/Annotation/Plugin.php b/core/lib/Drupal/Component/Annotation/Plugin.php
index 790440d11292..504ff401d1aa 100644
--- a/core/lib/Drupal/Component/Annotation/Plugin.php
+++ b/core/lib/Drupal/Component/Annotation/Plugin.php
@@ -39,7 +39,7 @@ public function __construct($values) {
       return $value !== NULL;
     });
     $parsed_values = $this->parse($values);
-    $this->definition = NestedArray::mergeDeep($defaults, $parsed_values);
+    $this->definition = NestedArray::mergeDeepArray([$defaults, $parsed_values], TRUE);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/Annotation/PluginTest.php b/core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
index d942764005fa..554ed8dbeccd 100644
--- a/core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
+++ b/core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
@@ -20,6 +20,7 @@ public function testGet() {
     // Assert all values are accepted through constructor and default value is
     // used for non existent but defined property.
     $plugin = new PluginStub([
+      1 => 'oak',
       'foo' => 'bar',
       'biz' => [
         'baz' => 'boom',
@@ -32,6 +33,7 @@ public function testGet() {
       // This property wasn't in our definition but is defined as a property on
       // our plugin class.
       'defaultProperty' => 'testvalue',
+      1 => 'oak',
       'foo' => 'bar',
       'biz' => [
         'baz' => 'boom',
-- 
GitLab