Mimicing overriden methods in PHP

PHP's lack of support for overriding methods is a real performance hog. You have to work out what the programmer meant by the types of the parameters sent to the method manually. All this takes time and has to be done every time the method is called.

You end up with code that looks like this:

/**
* I want to do something like calling myfunc(new Instance("thingstring")) or just
* myclass("thingstring");
*/
public function myfunc( $instance ) {
if (is_string($instance)) $instance=new Instance($instance);
if (!$instance instanceof Instance) throw new RuntimeException('oops!');
$this->_myfunc( $instance );
}

If PHP handled this properly it could cache the results so you only had to deal with the pain once.