Edit report at https://bugs.php.net/bug.php?id=52424&edit=1
ID: 52424
Comment by: nishant dot kanitkar at gmail dot com
Reported by: php-bugs at majkl578 dot cz
Summary: Function naming inconsistency: htmlentities() x
html_entity_decode()
Status: Wont fix
Type: Bug
Package: Unknown/Other Function
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
I don't see why this can't be done.
Alias the functions to a single standard and depreciate the old ones.
In the next version of PHP, add a configuration toggle ALLOW_LEGACY_FUNCTIONS set to default false.
If ALLOW_LEGACY_FUNCTIONS is true, all the depreciated functions work as expected.
If ALLOW_LEGACY_FUNCTIONS is false, all the depreciated functions throw errors.
Keep the toggle in all future versions of PHP. Eventually applications using the legacy function
names
will either run a search-and-replace or fall out of use. It wouldn't be too difficult to
migrate if the
only change is a name change.
Previous Comments:
------------------------------------------------------------------------
[2013-01-24 02:46:34] php at lavoie dot sl
The core functionsâ naming is one the most frowned upon "feature" of PHP and it
is well overdue for a refactor. Old frameworks and application are a pain to
convert, and it pretty pointless to do it for a cosmetic reason as rasmus pointed
out, but I think the core devs are underestimating how much the community wants
it done and how many people are willing to do their part.
Letâs face it:
â¢Â htmlentities/html_entity_decode
⢠str_replace/strtr
â¢Â current/array_pop
⢠array_push($array, $item)/array_search($item, $array)
I believe a very responsible roadmap would be to :
1. Create a PHP library that would essentially just wrap a function in another with consistent
naming and arguments order.
2. Get some feedback of the community and work on the names. The guys at FIG would probably be a
blessing on that.
3. Implement those using aliasing and a compiled extension.
4. Let it sit for a couple time while people get to know about it.
5. Merge extension into core. Real world application will begin to use it.
6. Drop the deprecated ones in a distant future.
------------------------------------------------------------------------
[2013-01-23 17:06:11] lenton64 at gmail dot com
I feel that this is a big problem in PHP. It makes it super hard to remember
function names (especially for newcomers) with these inconsistencies and gives
PHP an ugly syntax reputation.
Please change all function names to:
words_separated_with_underscore()
and then alias the original functions to the new ones.
It may take a long time for everyone to change the functions in their
applications but you can keep them aliased for however long everyone needs.
This naming convention needs to become a standard in PHP at some point, why not
get the ball rolling now.
------------------------------------------------------------------------
[2010-07-29 02:09:38] rasmus@php.net
We don't mind change, but our users really really don't like it when we break
their working applications for cosmetic reasons.
------------------------------------------------------------------------
[2010-07-29 02:05:31] php-bugs at majkl578 dot cz
Yes and that is what I think should change, because current naming conventions are really horrible.
For instance, look at differences between str_replace, strlen, parse_str, htmlspecialchars. All work
with same type but their names are completely different.
So, string functions should go to String namespace (String\replace()), array functions to Array
namespace (Array\search()) and so on.
But unfortunately this will not happen because PHP does not like changes... Think about it.
------------------------------------------------------------------------
[2010-07-25 00:19:32] giorgio dot liscio at email dot it
php functions uses a lot of different syntax
isset
is_array
isPublic
but aliasing is evil and renaming is not appreciated by users... the best thing you can do is
implement your renamed function in your namespace
bye
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=52424--
Edit this bug report at https://bugs.php.net/bug.php?id=52424&edit=1