title: PHPStorm type hinting subclasses of baseclass
body: <p>With respect to this post:</p>
  
  <p><a href="https://stackoverflow.com/q/26470325/178728">In PHPStorm, how can I make type hinting work when I have a superclass method that returns a different type from each subclass</a>,</p>
  
  <p>this one is about an edge case in PHPStorm type hinting. 
  Please try to follow along - I'll do my best to be as clear as possible:</p>
  
  <p>So, I've got this base abstract class:</p>
  
  <pre><code>abstract class myBaseController {
      protected $_model;
      ...
  }
  </code></pre>
  
  <p>which another class inherits from:</p>
  
  <pre><code>class myController extends myBaseController {
      $hello = 'hello';
      ...
  }
  </code></pre>
  
  <p>and which is further extended by a third class:</p>
  
  <pre><code>class myNewController extends myController {
      public $myvar;
      $this-&gt;_model = new myModel();
      ...
  
      public function myFunc(){
          // !!form is underlined as: "Method 'form' not found in class"!!
          $form = $this-&gt;_model-&gt;form($new_variable); 
      }
  </code></pre>
  
  <p>Below is a sample of the myModel class:</p>
  
  <pre><code>class myModel extends BaseModel {
      $world = 'world';
      public function form($my_variable) {
          do_something();
      }
  </code></pre>
  
  <hr>
  
  <p>My true question is how to properly "phpdoc" this scenario:</p>
  
  <p><strong>A subclass <code>myNewController</code> is using an inherited variable <code>_model</code> to assign an instance of another class <code>myModel</code> which has a unique function <code>form</code>. How should PHPStorm properly find out about <code>form</code> in <code>myNewController</code>?</strong></p>
  
  <p>My solution so far involves documenting <code>myBaseController</code> like this:</p>
  
  <pre><code>abstract class myBaseController {
      /**
       * @var object
       */
       protected $_model;
      ...
  }
  </code></pre>
  
  <p>However I think <code>@var object</code> is too broad (PHPStorm won't find its declaration) and my guess is that there should be a better (and more specific) way to do this.</p>
  
  <p>Maybe we could instead do: </p>
  
  <pre><code>/**
   * @var BaseModel
   */
  </code></pre>
  
  <p>if PHPStorm had a way of looking into the subclasses for the method.</p>
  
  <p>Any ideas?
  Thank you all in advance.</p>