Closed
Description
Hi guys!
Take the following class:
class ProductRepository
{
private $client;
private $logger;
public function __construct(Client $client, LoggerInterface $logger)
{
$this->client = $client;
$this->logger = $logger;
}
}
Since LoggerInterface
can't be injected yet (we're waiting on a MonologBundle tag), I wired it like this:
services:
product_repository:
class: AppBundle\Repository\ProductRepository
autowire: true
arguments:
1: '@logger'
Sure, it's weird to have the "1" in there, but I thought it would work. It almost did, but it reversed the arguments. In the cached container, this becomes:
new ProductRepository($this->get('logger'), $this->get('api_client'));
In YAML, I believe this is the only way to set one specific argument, without specifying all of them, and it looks like a bug :).
Especially because non-services can't be autowired yet, this probably the biggest issue left with autowiring (along with not being able to globally map a class/interface to a specific service id).
ping @dunglas
Thanks!