title: Preserving auto-completion abilities with Symfony2 Dependency Injection
body: <p>I'm using PHP Storm as my IDE, but I believe that other IDE's such as Netbeans will have the same issue as I'll explain below.</p>
  
  <p>When using a framework like Symfony2, we have the wonderful world of Dependency Injection added. So objects can simply be instantiated using code like the following snippet:</p>
  
  <pre><code>$myThingy = $this-&gt;get('some_cool_service');
  </code></pre>
  
  <p>This is very handy, as objects are already configured beforehand. The one problem is, that auto-completion breaks entirely in basically any PHP IDE, as the IDE does not know what type the get() method is returning.</p>
  
  <p>Is there a way to preserve auto-completion? Would creating for example an extension of Controller be the answer? For example:</p>
  
  <pre><code>class MyController extends Controller {
      /**
       * @return \MyNamespace\CoolService
       */
      public getSomeCoolService() {
          return new CoolService();
      }
  }
  </code></pre>
  
  <p>and then for application controllers, specify MyController as the base class instead of Controller?</p>
  
  <p>What about using a Factory class, or any other possible methods?</p>