Re: alias a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Thus wrote Justin French:
> Hi,
> 
> What's the quickest way to alias a user function?
> 
> I have a function which uses english spelling (eg categorise instead of 
> categorize), and I want to alias the function with an "Americanized" 
> spelling.
> 
> I'd rather that the alias categorize() did not have to be altered in 
> any way to "keep up" with changes to the parent function categorise() 
> -- in particular, having the correct number of attributes and default 
> values, for example.

Instead of aliasing, I would deprecate the function, so the old
function would be:

function categorise($arg1, $arg2) {
  trigger_error('Deprecated categorise used', E_USER_NOTICE);
  return categorize($arg1, $arg2);
}

As far eliminating the parameter changes, I can only think that
you'd need to use func_get_args() and call_user_func_array():

function categorise() {
  call_user_func_array('categorize', func_get_args());
}

The latter solution is quite a bit of overhead just to get an alias,
perhaps trigger_error with that method as you migrate old code.



Curt
-- 
Quoth the Raven, "Nevermore."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux