From: Andrei Zmievski Date: Mon, 1 May 2000 16:22:00 +0000 (+0000) Subject: Added a way to get all declared classes. X-Git-Tag: php-4.0RC2~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=164e4e50b9f2ceae9befd42ccad28e539e06a39d;p=php Added a way to get all declared classes. --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index e313123943..2e1581e7e5 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -54,6 +54,7 @@ static ZEND_FUNCTION(get_object_vars); static ZEND_FUNCTION(get_class_methods); static ZEND_FUNCTION(user_error); static ZEND_FUNCTION(set_user_error_handler); +static ZEND_FUNCTION(get_declared_classes); unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE }; unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW }; @@ -90,6 +91,7 @@ static zend_function_entry builtin_functions[] = { ZEND_FE(get_class_methods, NULL) ZEND_FE(user_error, NULL) ZEND_FE(set_user_error_handler, NULL) + ZEND_FE(get_declared_classes, NULL) { NULL, NULL, NULL } }; @@ -682,8 +684,12 @@ ZEND_FUNCTION(get_required_files) { CLS_FETCH(); + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + array_init(return_value); - zend_hash_apply_with_argument(&CG(used_files), (int (*)(void *, void *)) copy_import_use_file, return_value); + zend_hash_apply_with_argument(&CG(used_files), (apply_func_arg_t) copy_import_use_file, return_value); } /* }}} */ @@ -692,8 +698,12 @@ ZEND_FUNCTION(get_required_files) Returns an array with the file names that were include_once()'d */ ZEND_FUNCTION(get_included_files) { + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + array_init(return_value); - zend_hash_apply_with_argument(&EG(included_files), (int (*)(void *, void *)) copy_import_use_file, return_value); + zend_hash_apply_with_argument(&EG(included_files), (apply_func_arg_t) copy_import_use_file, return_value); } /* }}} */ @@ -756,3 +766,24 @@ ZEND_FUNCTION(set_user_error_handler) RETURN_TRUE; } + +static int copy_class_name(zend_class_entry *ce, zval *array) +{ + add_next_index_stringl(array, ce->name, ce->name_length, 1); + return 0; +} + +/* {{{ proto array get_declared_classes(void) + Returns an array of all declared classes. */ +ZEND_FUNCTION(get_declared_classes) +{ + CLS_FETCH(); + + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT; + } + + array_init(return_value); + zend_hash_apply_with_argument(CG(class_table), (apply_func_arg_t)copy_class_name, return_value); +} +/* }}} */