Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | 4.0 |
I propose to introduce @Autowire
annotation that will inject services into private / protected properties (the same way as Doctrine does with entities) instead of passing them to constructor. This can work like so:
class Service
{
/**
* @Autowire
* @var Symfony\Component\Routing\RouterInterface
*/
protected $router;
}
This would mimic Spring's @Autowired
annotation and allow simpler DI if necessary, especially when inheriting services (on a small performance cost of reflection call, which is to be measured). Of course, container - injection should stay.
Was this behaviour discussed before?