Closed
Description
Symfony version(s) affected
6.2.0
Description
The inner collection in the following code snippet is ignored:
<bind key="$foo" type="collection">
<bind key="inner-collection" type="collection">
<argument>item-1</argument>
<argument>item-2</argument>
</bind>
</bind>
How to reproduce
Bind a variable $foo
with the following code snippet in a container configuration file, and try to dump this variable in a controller, the inner collection will be empty:
<bind key="$foo" type="collection">
<bind key="inner-collection" type="collection">
<argument>item-1</argument>
<argument>item-2</argument>
</bind>
</bind>
Possible Solution
Change Symfony\Component\DependencyInjection\Loader\XmlFileLoader
as follows:
case 'collection':
- $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file);
+ $argumentName = 'bind' === $arg->parentNode->nodeName ? 'argument' : $name;
+ $arguments[$key] = $this->getArgumentsAsPhp($arg, $argumentName, $file);
Additional Context
No response