summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-05-01 16:22:00 +0000
committerAndrei Zmievski <andrei@php.net>2000-05-01 16:22:00 +0000
commit164e4e50b9f2ceae9befd42ccad28e539e06a39d (patch)
tree218cf16f33277a98edce0b28ad04858f8cf13ed4 /Zend/zend_builtin_functions.c
parente20cdc315e68ff4762eacf3f2da7e37192085420 (diff)
downloadphp-git-164e4e50b9f2ceae9befd42ccad28e539e06a39d.tar.gz
Added a way to get all declared classes.
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c35
1 files changed, 33 insertions, 2 deletions
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);
+}
+/* }}} */