I'm trying to use __callStatic to wrap the calls to differents static functions in my class.
This current version of the code allows me to do so with functions that have 0 or 1 parameter:
class test {
public static function __callStatic($name, $args) {
if (method_exists(__CLASS__, $name)) {
echo "it does exist\n";
return forward_static_call([__CLASS__, $name], $args[0]);
} else {
echo "it does not exist\n";
}
}
private static function mfunc($param1, $param2) {
echo "that's my func \n";
echo "$param1\n";
echo "$param2\n";
}
}
test::notafunc("one", 'two');
test::mfunc("one", "two");
However it will fail for mfunc since it has two parameters.
How can i spread the different arguments when i'm calling the function ?
I can't use the new spread operator because I am locked on PHP 7.2.
I can't modify mfunc either, because I have way too much methods to change in the project.
call_user_func_array()