You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #53582 [TwigBundle] Fix configuration when "paths" is null (smnandre)
This PR was merged into the 5.4 branch.
Discussion
----------
[TwigBundle] Fix configuration when "paths" is null
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | ..
| License | MIT
TwigBundle configuration throws an error when paths config is empty (found it while commenting a line)
```yaml
twig:
default_path: '%kernel.project_dir%/templates'
form_themes:
- 'form/form_theme.html.twig'
paths:
# '%kernel.project_dir%/templates/foo': Bar
```
```console
In Configuration.php line 159:
[ErrorException]
Warning: foreach() argument must be of type array|object, null given
Exception trace:
```
Triggered by this line
```diff
->arrayNode('paths')
->normalizeKeys(false)
->useAttributeAsKey('paths')
->beforeNormalization()
->always()
->then(function ($paths) {
$normalized = [];
- foreach ($paths as $path => $namespace) {
if (\is_array($namespace)) {
// xml
$path = $namespace['value'];
$namespace = $namespace['namespace'];
}
```
This PR replace `always` with `isArray` and add a test
Commits
-------
c72236b [TwigBundle] Fix configuration when 'paths' is null
0 commit comments