title: How can I make PHP handle functions' overloading errors?
body: <p>Lets assume I have a class called <code>Form</code>. This class uses the magic method <code>__call()</code> to add fields to itself like so:</p>
  
  <pre><code>&lt;?php
  class Form {
  
    private $_fields = array();
  
    public function __call($name, $args) {
  
      // Only allow methods which begin with 'add'
      if ( preg_match('/^add/', $name) ) {
  
         // Add a new field
  
      } else {
  
         // PHP throw the default 'undefined method' error
  
      }
  
    }  
  
  }
  </code></pre>
  
  <p>My problem is that I can't figure out how to make PHP handle the calls to undefined methods in it's default way. Of course, the default behavior can be mimicked in many ways, for example I use the following code right now:</p>
  
  <pre><code>trigger_error('Call to undefined method ' . __CLASS__ . '::' . $function, E_USER_ERROR);
  </code></pre>
  
  <p>But I don't like this solution because the error itself or its level might change in the future, so is there a better way to handle this in PHP? </p>
  
  <p><strong>Update</strong>
  Seems like my question is a little vague, so to clarify more... How can I make PHP throw the default error for undefined methods <em>without</em> the need to supply the error and it's level? The following code won't work in PHP, but it's what I'm trying to do:</p>
  
  <pre><code>// This won't work because my class is not a subclass. If it were, the parent would have             
  // handled the error 
  parent::__call($name, $args);
  
  // or is there a PHP function like...
  trigger_default_error(E_Undefined_Method);
  </code></pre>
  
  <p>If anyone is familiar with ruby, this can be achieved by calling the <code>super</code> method inside <code>method_missing</code>. How can I replicate that in PHP?</p>