Skip to content

Instantly share code, notes, and snippets.

Last active June 12, 2020 15:11
What would you like to do?
Simple API for overriding functions and method of classes
// APIs for overriding functions and methods of classes
override_class_function(string $class, string $method, Closure $callback);
override_function(string $function, Closure $callback);
call_orginal_function(array $params);
// Example of usage override_function()
override_function('curl_exec', function(){
$params = func_get_args();
echo "--- BEFORE ---";
$result = call_original_function($params);
echo "--- AFTER ---";
return $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment