PhpStorm does not recognize Doctrine's default entity manager
<p>I have the following code :</p>

<pre><code>$repo = $this-&gt;get('doctrine.orm.default_entity_manager')
    -&gt;getRepository('Acme:Foo');
</code></pre>

<p>For the record, the code is working correctly since I can use <code>$repo</code>, its methods and the resulting entities without a problem.</p>

<p>However PhpStorm highlights the <code>'doctrine.orm.default_entity_manager'</code> string and gives me the following error:</p>

<blockquote>
  <p>Missing service</p>
</blockquote>

<p>I get the same error in my services files when referencing that particular service. Following that, obviously, autocomplete does not work. I can use the following workaround, of course:</p>

<pre><code>/** @var \Doctrine\ORM\EntityManager $em */
$em = $this-&gt;get('doctrine.orm.default_entity_manager');
$em-&gt;getRepository('Acme:Foo');
</code></pre>

<p>This way I still get a warning but autocompletion works properly. However, I'd rather keep my code clean from this kind of annotation as much as possible, plus I'm almost sure there's an easy fix for that. I have of course cleared my cache multiple times.</p>

<p>How can I fix this?</p>

<p>EDIT: I need to mention I'm using the Symfony2 plugin.</p>