diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index 88793bc21777f0fdb79ac8f1f2a552972acbb0dd..1fd24219c5ca2cb5443871370afad1152165b27f 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -95,7 +95,13 @@ public static function children(array &$elements, $sort = FALSE) { // Only trigger an error if the value is not null. // @see https://www.drupal.org/node/1283892 elseif (isset($value)) { - trigger_error(new FormattableMarkup('"@key" is an invalid render array key', ['@key' => $key]), E_USER_ERROR); + trigger_error(new FormattableMarkup( + '"@key" is an invalid render array key. Value should be an array but got a @type', + [ + '@key' => $key, + '@type' => gettype($value), + ] + ), E_USER_ERROR); } } $i++; diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php index 31f3a7b8a2c6fc4a9ef8928d157515d98058c4f0..5795e8da7a1b222487a717825a92d13fd6b0ba81 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php @@ -109,7 +109,7 @@ public function testInvalidChildren() { 'foo' => 'bar', ]; $this->expectError(); - $this->expectErrorMessage('"foo" is an invalid render array key'); + $this->expectErrorMessage('"foo" is an invalid render array key. Value should be an array but got a string'); Element::children($element); }