Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created September 30, 2015 01:16
Show Gist options
  • Save lgedeon/63ab627c39a708a4eca5 to your computer and use it in GitHub Desktop.
Save lgedeon/63ab627c39a708a4eca5 to your computer and use it in GitHub Desktop.
Replace a method in a global object. Not working yet. Just a concept that I discovered I didn't actually need.
class Better_Broken_Class extends Broken_Class {
private $parent = null;
function __construct ( $parent ) {
$this->parent = $parent;
}
function __call ( $name, $arguments ) {
if ( 'function_to_replace' === $name ) {
// do other stuff and return
}
call_user_func_array( array( $this->parent, $name ), $arguments );
}
}
global $broken_object;
$broken_object = new Better_Broken_Class( $broken_object );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment