|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-20 10:27 UTC] jobapply at nextmail dot ru
Description:
------------
Can't add a method with mixed-case naming.
Like 'Test', 'getA' ...
Reproduce code:
---------------
class Example {
}
runkit_method_add(
'Example',
'Test',
'',
'return 5;',
RUNKIT_ACC_PUBLIC
);
$e = new Example();
echo $e->Test();
Expected result:
----------------
5
Actual result:
--------------
PHP Fatal error: Call to undefined method Example::Test() in /var/site/setter/reproduce2.php on line 18
Fatal error: Call to undefined method Example::Test() in /var/site/setter/reproduce2.php on line 18
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 10:00:01 2025 UTC |
@Daniel: strcmp is fine. Function table always has lower-case entries. Entries into the function_table (zend_hash_add, ...) need to be performed with lowercase functionnames. Calls to get_class_methods will still show the mixed-case-variant since that's stored together with the function (separate of the function_table). Testcase for direct as well as indirect calls to function with mixed-case as well as listing function names: <? class Foo { function a() { self::barB(); } } runkit_method_add("Foo","barB",'',"return;"); print_r(get_class_methods("Foo")); Foo::barB(); Foo::a(); Tested fix for the problem: --- runkit_methods.c.orig 2007-12-27 22:16:05.000000000 +0100 +++ runkit_methods.c 2009-07-22 02:32:02.000000000 +0200 @@ -344,6 +344,7 @@ func.common.fn_flags |= ZEND_ACC_ALLOW_STATIC; #endif + php_strtolower(methodname, methodname_len); zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)php_runkit_update_children_methods, 5, ancestor_class, ce, &func, methodname, methodname_len);