Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c72236b

Browse files
committed
[TwigBundle] Fix configuration when 'paths' is null
1 parent 4460eb4 commit c72236b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
147147
->normalizeKeys(false)
148148
->useAttributeAsKey('paths')
149149
->beforeNormalization()
150-
->always()
150+
->ifArray()
151151
->then(function ($paths) {
152152
$normalized = [];
153153
foreach ($paths as $path => $namespace) {

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ public function testArrayKeysInGlobalsAreNotNormalized()
5252

5353
$this->assertSame(['global' => ['value' => ['some-key' => 'some-value']]], $config['globals']);
5454
}
55+
56+
public function testNullPathsAreConvertedToIterable()
57+
{
58+
$input = [
59+
'paths' => null,
60+
];
61+
62+
$processor = new Processor();
63+
$config = $processor->processConfiguration(new Configuration(), [$input]);
64+
65+
$this->assertSame([], $config['paths']);
66+
}
5567
}

0 commit comments

Comments
 (0)