title: JMS DI Extra Bundle: How do I inject a dependency only if it exists
body: <p>I am using JMS DI to inject services with annotation: </p>
  
  <pre><code>use JMS\DiExtraBundle\Annotation as DI;
  /**
   * @DI\Service("foo.bar.service")
   */
  class myClass
  {
      /**
      * @DI\Inject("debug.stopwatch")
      * @var $stopWatch \Symfony\Component\Stopwatch\Stopwatch
      */
      public $stopWatch;
  
      /**
      * @DI\Inject("serializer")
      * @var $serializer \JMS\Serializer\Serializer
      */
      public $serializer;
  
      public function toto()
      {
         if (isset($this-&gt;stopwatch)) {
           $this-&gt;stopWatch-&gt;start("init");
         }
      }
  }
  </code></pre>
  
  <p>But StopWatch is only available in Dev Env, so when running in prod:</p>
  
  <pre><code>The service "foo.bar.service" has a dependency on a non-existent service "debug.stopwatch".' in...
  </code></pre>
  
  <p>My question: <strong>How can i inject the stopwatch service properly in my class ?</strong> </p>