Description
Symfony version(s) affected: ^5.3.0
Description
When using the new feature for defining multiple environments in a single config files, you cannot import a file containing the when@{env}
key. Although it is valid, it won't be used. Within the YamlFileLoader I found that when importing the files the environment property is temporary unset and is restored after finishing the import.
I don't know if this is an actual bug since it looks like this feature is not available in imported files on purpose.
How to reproduce
config.yml
imports:
- { resource: profiler.yml }
profiler.yml
when@dev:
web_profiler:
toolbar: true
when@test:
web_profiler:
toolbar: false
Possible Solution
I looked at the YamlFileLoader and discovered that the environment was unset after loading the initial file (containing the import). I think it should be possible to remove this logic and have it work in imports too.