-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels

Description
Symfony version(s) affected: 4.3.4
Description
In Symfony 4.2 the logger service could be injected by type. After upgrading to 4.3.4 I can only inject it by using the argument name.
How to reproduce
// MyClass.php
namespace App\MyNamespace;
use Psr\Log\LoggerInterface;
class MyClass
{
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
}
# services.yaml
services:
App\MyNamespace\MyClass:
arguments:
Psr\Log\LoggerInterface: '@monolog.logger.my_channel'
In Symfony 4.3.4 I get the following error message:
In ResolveNamedArgumentsPass.php line 57:
Invalid service "App\MyNamespace\MyClass": did you forget to add the "$" prefix to argument "Psr\Log\LoggerInterface"?
It can be fixed by using a the argument name in services.yaml:
# services.yaml
services:
App\MyNamespace\MyClass:
arguments:
$logger: '@monolog.logger.my_channel'
I wonder why the injection by type does not work anymore.