From aac47f0d69b3c861ee65b7f87d4059e5a5a4cb05 Mon Sep 17 00:00:00 2001 From: catch Date: Sun, 19 Nov 2023 18:02:13 +0000 Subject: [PATCH] Issue #3402548 by alexpott, mikelutz, el7cosmos: YamlFileLoaderTest fails if you have PECL yaml installed --- .../Drupal/Core/DependencyInjection/YamlFileLoader.php | 4 ++-- .../Tests/Core/DependencyInjection/YamlFileLoaderTest.php | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php index a1b81d261e7..f42b6115f8a 100644 --- a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php +++ b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php @@ -450,8 +450,8 @@ class YamlFileLoader throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } - if ($invalid_keys = array_diff_key($content, array('parameters' => 1, 'services' => 1))) { - throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid keys %s. Services have to be added under "services" and Parameters under "parameters".', $file, $invalid_keys)); + if ($invalid_keys = array_keys(array_diff_key($content, array('parameters' => 1, 'services' => 1)))) { + throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid root key(s) "%s". Services have to be added under "services" and Parameters under "parameters".', $file, implode('", "', $invalid_keys))); } return $content; diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php index 06e40a0e3c5..6462a473f00 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/YamlFileLoaderTest.php @@ -171,10 +171,16 @@ YAML, ], 'YAML must be valid' => [<< [<<