Rename a function, so that a function can be called with the new name

function fb_rename_function(
  string $orig_func_name,
  string $new_func_name,
): bool;

When writing unit tests, one may want to stub out a function. To do so, call fb_rename_function('func_to_stub_out', 'somename') then fb_rename_function('new_func_to_replace_with', 'func_to_stub_out'). This way, when calling func_to_stub_out(), it will actually execute new_func_to_replace_with().


  • string $orig_func_name - Which function to rename.
  • string $new_func_name - What is the new name.


  • bool - - TRUE if successful, FALSE otherwise.