Created
September 30, 2015 01:16
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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