title: PHPDoc and PhpStorm: indicate the return type of a magic method
body: <p>In general, this is how I get my IDE (PhpStorm 2017) to recognize the type of a variable that I don't get to formally declare:</p>
  
  <pre><code>/*
   * @var User $user
  */
  foreach($users as $user){}
  </code></pre>
  
  <p>The IDE knows then that <code>$user</code> is of class <code>User</code>.  Now I'm facing a situation with this line:</p>
  
  <pre><code>Yii::app()-&gt;user-&gt;login()
  </code></pre>
  
  <p>Specifically, the IDE has no idea what type <code>user</code> is. I get the warning:</p>
  
  <blockquote>
    <p>Field accessed via magic method</p>
  </blockquote>
  
  <p>So I tried to specify with:</p>
  
  <pre><code>/**
   * @var User Yii::app()-&gt;user
   */
  Yii::app()-&gt;user-&gt;login();
  </code></pre>
  
  <p>But that doesn't make a difference. How can I help the IDE resolve the type?</p>