From c72236b1301bbc8253c2dfe216e183fc52aa0b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Fri, 19 Jan 2024 03:20:37 +0100 Subject: [PATCH] [TwigBundle] Fix configuration when 'paths' is null --- .../TwigBundle/DependencyInjection/Configuration.php | 2 +- .../Tests/DependencyInjection/ConfigurationTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 76faa0107e374..36b05857546de 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -147,7 +147,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode) ->normalizeKeys(false) ->useAttributeAsKey('paths') ->beforeNormalization() - ->always() + ->ifArray() ->then(function ($paths) { $normalized = []; foreach ($paths as $path => $namespace) { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php index 41627c48041e3..6ed43087579ce 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -52,4 +52,16 @@ public function testArrayKeysInGlobalsAreNotNormalized() $this->assertSame(['global' => ['value' => ['some-key' => 'some-value']]], $config['globals']); } + + public function testNullPathsAreConvertedToIterable() + { + $input = [ + 'paths' => null, + ]; + + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(), [$input]); + + $this->assertSame([], $config['paths']); + } }