#47213 [Opn->Bgs]: include rename_function() in standard library
| From: | johannes@php.net | Date: | Sun, 25 Jan 2009 21:49:14 +0000 |
| Subject: | #47213 [Opn->Bgs]: include rename_function() in standard library | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133208@lists.php.net to get a copy of this message | ||
ID: 47213
Updated by: johannes@php.net
Reported By: rasmus at mindplay dot dk
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: all
PHP Version: 5.2.8
New Comment:
It's here for people who _really_ want it, but we certainly won't make
this a default function as 99% of the probable use cases are bad deign
of PHP applications or other mistakes. In your case see
spl_autoload_register() which does exactly what you want.
Previous Comments:
------------------------------------------------------------------------
[2009-01-25 16:35:00] rasmus at mindplay dot dk
Description:
------------
Please consider including this function in the standard library:
http://us3.php.net/rename_function
This would enable techniques as shown below.
I know this is a duplicate of feature request #37078, which was bluntly
rejected without explanation, before anyone had a chance to review or
comment on this idea.
Reproduce code:
---------------
<?php
// example -
// install an autoload handler that preserves an existing handler:
if (function_exists('__autoload')) {
rename_function('__autoload', '__autoload_old');
}
function __autoload($class_name) {
if (function_exists('__autoload_old') {
try {
__autoload_old($class_name);
catch ($e) {
// my own autoloader here..
}
}
}
?>
Another example would be the ability to extend existing PHP functions
with new functionality, like calculating default arguments or enhancing
the behavior of certain functions. Example: the array_chunk function
only works with real arrays - you could override it with a function that
works with iterable objects as well.
Expected result:
----------------
This would work - you could override this magic function and preserve
any existing autoloader.
This would enable you to combine autoloaders from different projects.
Actual result:
--------------
The function is not generally available on standard PHP installations.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47213&edit=1