title: Symfony 3.3 Dependency Injection changes
body: <p>In Synfony 3.3, the new best practice for DI </p>
  
  <blockquote>
    <p>is to use normal constructor dependency injection (or "action"
    injection in controllers) instead of fetching public services via
    $this->get() (though that does still work)</p>
  </blockquote>
  
  <p><a href="https://symfony.com/doc/current/service_container/3.3-di-changes.html#controllers-are-registered-as-services" rel="nofollow noreferrer">as seen in offical documentation</a></p>
  
  <p>So no need to specify services as we can type hint them in class controllers :</p>
  
  <pre><code>class InvoiceMailer
  {
      private $generator;
  
      public function __construct(InvoiceGenerator $generator)
      {
          $this-&gt;generator = $generator
      }
  
      // ...
  }
  </code></pre>
  
  <p>This seems to work well, but what if I extends a class and add more parameters in my constructors ???</p>
  
  <pre><code>use Symfony\Component\HttpKernel\Exception\HttpException;
  
  class MyClass extends HttpException
  {
      private $generator;
  
      public function __construct(InvoiceGenerator $generator, \Exception $previous = null, array $headers = [], $code = 0)
      {
          $this-&gt;generator = $generator;
          $statusCode      = $generator-&gt;getStatusCode();
          $message         = $generator-&gt;getTitle();
  
          parent::__construct($statusCode, $message, $previous, $headers, $code);
      }
  
      // ...
  }
  </code></pre>
  
  <p>Now I get a circular reference error :</p>
  
  <blockquote>
    <p>[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]
    Circular reference detected for service "AppBundle\Service\MyClass", path: "AppBundle\Service\MyClass -> AppBundle\Service\MyClass".</p>
  </blockquote>
  
  <p>So, what is the best practice in this case ??</p>
  
  <p>Thanks.</p>