title: How to deal with "method not found in class" warning for magically implemented methods?
body: <p>I am sitting on a large codebase that contains several classes that expose functionality through magically implemented methods (using <code>__call</code> and <code>__callStatic</code>). For example:</p>
  
  <pre><code>class Foo {
      public function __call($name, $parameters) {
          echo "You called $name().\n";
      }
  }
  
  $f = new Foo;
  $f-&gt;test();   // runs fine, but PhpStorm flags as a warning
  </code></pre>
  
  <p>The problem is that PhpStorm thinks that the <code>test()</code> method does not exist, so it gives a warning at the call site. This is a little annoying, as of course the code will run and behave as expected.</p>
  
  <p>I have already tuned down the severity by checking the "downgrade severity if __magic methods are present in class" option, but I would prefer to either:</p>
  
  <ol>
  <li>completely disable this functionality for specific classes <em>only</em>, or</li>
  <li>work with the IDE rather than against it -- provide it with the information I already have so our views agree</li>
  </ol>
  
  <p><strong>Is any of the above possible? If so, how?</strong></p>
  
  <p>Additional bonus question: consider the case where method calls are being chained.</p>
  
  <pre><code>$f = new Foo;
  $f-&gt;test()-&gt;chain()-&gt;moreChain();   // potentially runs fine
  </code></pre>
  
  <p>Assuming that the magic call to <code>$f-&gt;test()</code> returns something appropriate the subsequent (possibly, but not necessarily, also magic) calls will work fine. However, since there is no way that I know of to tell the IDE what <code>test()</code> returns it flags the rest of the call chain as full of missing methods too. And to make matters worse, the "downgrade severity" setting does not apply to these warnings since the IDE does not know what class these intermediate objects are supposed to be.</p>
  
  <p><strong>Is there a solution that can also cover this case?</strong></p>
  
  <h2>Update</h2>
  
  <p>Even though documenting the magic methods with <code>@method</code> annotations seems to work, I have to assume that there are currently several problems with this approach because it only took me a little work to come upon these related bugs:</p>
  
  <ul>
  <li><a href="http://youtrack.jetbrains.com/issue/WI-13654">Type hinting for the method arguments does not work correctly with primitives</a></li>
  <li><a href="http://youtrack.jetbrains.com/issue/WI-13731">Annotations work for one call, but not for chained calls</a></li>
  </ul>
  
  <p>I do hope they fix them in a reasonable time frame.</p>