|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-23 17:48 UTC] mattsch at gmail dot com
Description:
------------
rename_function should be not case-sensitive as that seems to conflict with php which specifically states that its functions aren't case sensitive.
Reproduce code:
---------------
function testFunc(){
echo 'test';
}
rename_function('testFunc','testFuncOther');
Outputs this:
PHP Warning: rename_function(testFunc, testFuncOther) failed: testFunc does not exist!
Workaround:
function testFunc(){
echo 'test';
}
rename_function('testfunc','testFuncOther');
Expected result:
----------------
Rename the function.
Actual result:
--------------
Only renames if the original function name is specified in lower case.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 23:00:01 2025 UTC |
Here is a patch to fix this. --- orig.c 2008-06-17 10:27:26.000000000 +1000 +++ php_apd.c 2008-06-17 11:24:41.000000000 +1000 @@ -663,6 +663,7 @@ PHP_FUNCTION(rename_function) { zval **z_orig_fname, **z_new_fname; + char *orig_fname; zend_function *func, *dummy_func; if( ZEND_NUM_ARGS() != 2 || @@ -671,6 +672,13 @@ ZEND_WRONG_PARAM_COUNT(); } + orig_fname = Z_STRVAL_PP(z_orig_fname); + /* Convert to to lower case */ + for(i = 0; i < Z_STRLEN_PP(z_orig_fname); i++) + if ((orig_fname[i] > 64) && (orig_fname[i] < 91)) + orig_fname[i] += 32; + Z_STRVAL_PP(z_orig_fname) = orig_fname; + convert_to_string_ex(z_orig_fname); convert_to_string_ex(z_new_fname);Whoops, missed a variable, this patch fixes this... --- orig.c 2008-06-17 10:27:26.000000000 +1000 +++ php_apd.c 2008-06-17 11:26:55.000000000 +1000 @@ -663,6 +663,8 @@ PHP_FUNCTION(rename_function) { zval **z_orig_fname, **z_new_fname; + char *orig_fname; + int i; zend_function *func, *dummy_func; if( ZEND_NUM_ARGS() != 2 || @@ -671,6 +673,13 @@ ZEND_WRONG_PARAM_COUNT(); } + orig_fname = Z_STRVAL_PP(z_orig_fname); + /* Convert to to lower case */ + for(i = 0; i < Z_STRLEN_PP(z_orig_fname); i++) + if ((orig_fname[i] > 64) && (orig_fname[i] < 91)) + orig_fname[i] += 32; + Z_STRVAL_PP(z_orig_fname) = orig_fname; + convert_to_string_ex(z_orig_fname); convert_to_string_ex(z_new_fname);