summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-03-23 17:47:28 +0000
committerAndrei Zmievski <andrei@php.net>2000-03-23 17:47:28 +0000
commit40e99c5e9fa879d2f1543392f23a1155bef5a85f (patch)
tree67cf2ab2d9cc5113490ce9f2cd0d5823b71d8323 /Zend/zend_builtin_functions.c
parent326f69f54e6fcd020ff81730ef81841f5896ab1a (diff)
downloadphp-git-40e99c5e9fa879d2f1543392f23a1155bef5a85f.tar.gz
Added get_class_methods().
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 770bebfcca..3ffd18b274 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -53,6 +53,7 @@ static ZEND_FUNCTION(get_included_files);
static ZEND_FUNCTION(is_subclass_of);
static ZEND_FUNCTION(get_class_vars);
static ZEND_FUNCTION(get_object_vars);
+static ZEND_FUNCTION(get_class_methods);
unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
@@ -86,6 +87,7 @@ static zend_function_entry builtin_functions[] = {
ZEND_FE(is_subclass_of, NULL)
ZEND_FE(get_class_vars, NULL)
ZEND_FE(get_object_vars, NULL)
+ ZEND_FE(get_class_methods, NULL)
{ NULL, NULL, NULL }
};
@@ -503,6 +505,46 @@ ZEND_FUNCTION(get_object_vars)
}
/* }}} */
+/* {{{ proto array get_class_methods(string class_name)
+ Returns an array of class methods' names */
+ZEND_FUNCTION(get_class_methods)
+{
+ zval **class_name;
+ zval *method_name;
+ char *lcname;
+ zend_class_entry *ce;
+ char *string_key;
+ ulong num_key;
+ int key_type;
+ CLS_FETCH();
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
+ RETURN_FALSE;
+ }
+
+ convert_to_string_ex(class_name);
+ lcname = estrndup((*class_name)->value.str.val, (*class_name)->value.str.len);
+ zend_str_tolower(lcname, (*class_name)->value.str.len);
+
+ if (zend_hash_find(CG(class_table), lcname, (*class_name)->value.str.len+1, (void **)&ce)==FAILURE) {
+ efree(lcname);
+ RETURN_NULL;
+ } else {
+ efree(lcname);
+ array_init(return_value);
+ zend_hash_internal_pointer_reset(&ce->function_table);
+ while ((key_type = zend_hash_get_current_key(&ce->function_table, &string_key, &num_key)) != HASH_KEY_NON_EXISTANT) {
+ if (key_type == HASH_KEY_IS_STRING) {
+ MAKE_STD_ZVAL(method_name);
+ ZVAL_STRING(method_name, string_key, 0);
+ zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL);
+ }
+ zend_hash_move_forward(&ce->function_table);
+ }
+ }
+}
+/* }}} */
+
/* {{{ proto bool method_exists(object object, string method)
Checks if the class method exists */
ZEND_FUNCTION(method_exists)