summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_builtin_functions.c52
-rw-r--r--Zend/zend_constants.c3
-rw-r--r--Zend/zend_errors.h5
3 files changed, 56 insertions, 4 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 7b5364ae98..bed8b82b3a 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -46,12 +46,13 @@ static ZEND_FUNCTION(leak);
#ifdef ZEND_TEST_EXCEPTIONS
static ZEND_FUNCTION(crash);
#endif
-static ZEND_FUNCTION(get_used_files);
+static ZEND_FUNCTION(get_required_files);
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);
+static ZEND_FUNCTION(user_error);
unsigned char first_arg_force_ref[] = { 1, BYREF_FORCE };
unsigned char first_arg_allow_ref[] = { 1, BYREF_ALLOW };
@@ -80,12 +81,13 @@ static zend_function_entry builtin_functions[] = {
#ifdef ZEND_TEST_EXCEPTIONS
ZEND_FE(crash, NULL)
#endif
- ZEND_FE(get_used_files, NULL)
+ ZEND_FE(get_required_files, NULL)
ZEND_FE(get_included_files, NULL)
ZEND_FE(is_subclass_of, NULL)
ZEND_FE(get_class_vars, NULL)
ZEND_FE(get_object_vars, NULL)
ZEND_FE(get_class_methods, NULL)
+ ZEND_FE(user_error, NULL)
{ NULL, NULL, NULL }
};
@@ -672,17 +674,61 @@ static int copy_import_use_file(zend_file_handle *fh, zval *array)
}
-ZEND_FUNCTION(get_used_files)
+/* {{{ proto array get_required_files(void)
+ Returns an array with the file names that were require_once()'d */
+ZEND_FUNCTION(get_required_files)
{
CLS_FETCH();
array_init(return_value);
zend_hash_apply_with_argument(&CG(used_files), (int (*)(void *, void *)) copy_import_use_file, return_value);
}
+/* }}} */
+/* {{{ proto array get_included_files(void)
+ Returns an array with the file names that were include_once()'d */
ZEND_FUNCTION(get_included_files)
{
array_init(return_value);
zend_hash_apply_with_argument(&EG(included_files), (int (*)(void *, void *)) copy_import_use_file, return_value);
}
+/* }}} */
+
+
+/* {{{ proto void user_error(string messsage [, int error_type])
+ Generates a user-level error/warning/notice message */
+ZEND_FUNCTION(user_error)
+{
+ int error_type = E_USER_NOTICE;
+ zval **z_error_type, **z_error_message;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 1:
+ if (zend_get_parameters_ex(1, &z_error_message)==FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ break;
+ case 2:
+ if (zend_get_parameters_ex(2, &z_error_message, &z_error_type)==FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ convert_to_long_ex(z_error_type);
+ error_type = (*z_error_type)->value.lval;
+ switch (error_type) {
+ case E_USER_ERROR:
+ case E_USER_WARNING:
+ case E_USER_NOTICE:
+ break;
+ default:
+ zend_error(E_WARNING, "Invalid error type specified");
+ RETURN_FALSE;
+ break;
+ }
+ break;
+ }
+ convert_to_string_ex(z_error_message);
+ zend_error(error_type, (*z_error_message)->value.str.val);
+ RETURN_TRUE;
+}
+/* }}} */
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index ee200b1964..c09e271f8e 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -108,6 +108,9 @@ void zend_register_standard_constants(ELS_D)
REGISTER_MAIN_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS);
diff --git a/Zend/zend_errors.h b/Zend/zend_errors.h
index 8c5548dad5..52615770f0 100644
--- a/Zend/zend_errors.h
+++ b/Zend/zend_errors.h
@@ -29,8 +29,11 @@
#define E_CORE_WARNING (1<<5L)
#define E_COMPILE_ERROR (1<<6L)
#define E_COMPILE_WARNING (1<<7L)
+#define E_USER_ERROR (1<<8L)
+#define E_USER_WARNING (1<<9L)
+#define E_USER_NOTICE (1<<10L)
-#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)
+#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
#endif /* _ZEND_ERRORS_H */