Re: alias a function

From: Date: Wed, 27 Oct 2004 03:46:47 +0000
Subject: Re: alias a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200400@lists.php.net to get a copy of this message
* 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."

« previous php.general (#200400) next »