title: Must declaration of the child class method be compatible with parent class method in PHP?
body: <p><strong>This code is running fine.</strong> </p>
  
  <p>The <code>ParentClass</code> is abstract class. I think I can verify that by </p>
  
  <pre><code>$class = new ReflectionClass('ParentClass');
  $methods = $class-&gt;getMethods(ReflectionMethod::IS_ABSTRACT);
  </code></pre>
  
  <p>which shows a couple of methods, one of which is named <code>methodA</code>.</p>
  
  <p><strong>Here comes what really baffled me:</strong></p>
  
  <p>There is a <code>ChildClass</code> and it is a concrete class and implements one of the abstract method <code>methodA</code>. Using </p>
  
  <pre><code>$method = new ReflectionMethod('ChildClass', 'methodA');
  var_dump($method-&gt;getParameters());
  </code></pre>
  
  <p>I can verify that there are 3 parameters. Since I know the code is working good. I used the same ReflectionMethod to verify the <code>ParentClass</code></p>
  
  <pre><code>$method = new ReflectionMethod('ParentClass', 'methodA');
  var_dump($method-&gt;getParameters());
  </code></pre>
  
  <p>This output an empty array which indicates none parameters, I suppose.</p>
  
  <p><strong>Why? Sadly, I can't look at the source code of these classes but I have been trying to figure out this without much progress:</strong> </p>
  
  <p>So far, I can only do things like this. The code is in PHP5.4. I really can't figure out how to make an abstract method <code>_myFunction</code> without arguments but the concrete child class method with 3 arguments. PHP uses <code>__call</code> to overload but this is more of a <code>extending</code> issue, I suppose.</p>
  
  <pre><code>class A {}
  
  abstract class MyAbstractClass
  {   
      //abstract public function _myFunction();// ERROR
      abstract public function _myFunction(A $a, A $b, A $c);
  }
  
  class Foobar extends MyAbstractClass
  {   
      public function _myFunction(A $a, A $b, A $c = null)
      {   
          echo "abc";
      }
  }
  
  $a = new Foobar();
  $a-&gt;_myFunction(new A(), new A(), new A());
  $a-&gt;_myFunction(new A(), new A());
  
  //output: abcabc without error
  </code></pre>
  
  <p>Added:</p>
  
  <p>After writing down the question, it helps me to further my test, I think I know why now. The child method has given all 3 arguments a default value.</p>
  
  <pre><code>class Foobar extends MyAbstractClass
  {   
      public function _myFunction(A $a = null, A $b = null, A $c = null)
      {
          echo "abc";
      }
  }
  </code></pre>
  
  <p>This would work.</p>