Last active
June 12, 2020 15:11
-
-
Save ezimuel/ac07dd3ff4ca321b608de185c52ef3c2 to your computer and use it in GitHub Desktop.
Simple API for overriding functions and method of classes
This file contains 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
<?php | |
// 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