Like class_alias but for functions:
<?php
function function_alias ($original, $alias) {
$args = func_get_args();
assert('count($args) == 2', 'function_alias() require exactly two arguments');
assert('is_string($original) && is_string($alias)', 'function_alias() require string arguments');
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][\\\\\\\\a-zA-Z0-9_\x7f-\xff]*$/\', $original) > 0',
"'$original' is not a valid function name");
assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][\\\\\\\\a-zA-Z0-9_\x7f-\xff]*$/\', $alias) > 0',
"'$alias' is not a valid function name");
$aliasNamespace = substr($alias, 0, strrpos($alias, '\\') !== false ? strrpos($alias, '\\') : 0);
$aliasName = substr($alias, strrpos($alias, '\\') !== false ? strrpos($alias, '\\') + 1 : 0);
$serializedOriginal = var_export($original, true);
eval("
namespace $aliasNamespace {
function $aliasName () {
return call_user_func_array($serializedOriginal, func_get_args());
}
}
");
}
?>
Until hopefully function_alias is added to php...