Closed
Description
Q | A |
---|---|
Bug report? | yes/no |
Feature request? | yes/no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3 |
Hello,
I'm wondering how to configure named argument with variadics parameter and autowire.
Please look at these example classes:
class Bar
{
}
class Foo
{
public function __construct(PropertyAccessorInterface $propertyAccessor, Bar ...$bars)
{
// ...
}
}
As we can see, class Foo
has $bars
constructor param as a variadic.
Without autowire i can configure it as presented below:
bar1:
class: Bar
bar2:
class: Bar
Foo:
arguments:
- '@property_accessor'
- '@bar1'
- '@bar2'
Now, i would like to use autowire
feature, but i don't know how to configure it.
Below config doesn't work - exception Type error: Argument 2 passed to Foo::__construct() must be an instance of Bar, array given
:
Foo:
autowire: true
arguments:
$bars:
- '@bar1'
- '@bar2'
Below config works but only last service is injected:
Foo:
autowire: true
arguments:
$bars: '@bar1'
$bars: '@bar2'
Is there any way to configure it properly?
Thanks.