title: Type hinting in interface
body: <p>Why should the class type-hint be 100% same with the interface?<br>
  I mean, why can't it accept implementing class as type hint?</p>
  
  <p>To make it clear,</p>
  
  <pre><code>&lt;?php
  interface MyInterface
  {
      public function doMethod(SomeInterface $a)
      {
      }
  }
  
  class MyClass implements MyInterface
  {
      public function doMethod(ClassThatImplementsSomeInterface $a)
       {
       }
  }
  </code></pre>
  
  <p>Error: <code>Fatal error: Declaration of MyClass::doMethod() must be compatible with that of MyInterface::doMethod()</code> </p>
  
  <p>Since the class type hinting implements <code>SomeInterface</code>, I expect it doesn't break the contract.<br>
  Why do I want it? Because of the advantages of interface flexibility.<br>
  The same goes for abstract class.<br>
  If I rewrite the code so that method 'do' has no type-hint, I know that it will 'fix' it.<br>
  But, somehow I think I should define the contract that type-hinting of <code>$a</code> must implement <code>SomeInterface</code>.<br>
  And, Why don't I just use the same type-hint which is <code>SomeInterface</code> ?<br>
  That's because there are methods that don't exist in <code>SomeInterface</code> that I need.<br>
  So, what's the point of this limitation?</p>
  
  <p>Reproducable codepad: <a href="http://codepad.org/2PLd8AmV" rel="noreferrer">http://codepad.org/2PLd8AmV</a></p>