php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #62343
Patch bug62343.phpt revision 2012-06-22 09:29 UTC by laruence@php.net
Patch bug62343.patch revision 2012-06-22 09:28 UTC by laruence@php.net

Patch bug62343.patch for Class/Object related Bug #62343

Patch version 2012-06-22 09:28 UTC

Return to Bug #62343 | Download this patch
Patch Revisions:

Developer: laruence@php.net

diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index eab98ed..f3425e0 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1476,7 +1476,6 @@ ZEND_FUNCTION(get_included_files)
 }
 /* }}} */
 
-
 /* {{{ proto void trigger_error(string message [, int error_type])
    Generates a user-level error/warning/notice message */
 ZEND_FUNCTION(trigger_error)
@@ -1506,7 +1505,6 @@ ZEND_FUNCTION(trigger_error)
 }
 /* }}} */
 
-
 /* {{{ proto string set_error_handler(string error_handler [, int error_types])
    Sets a user-defined error handler function.  Returns the previously defined error handler, or false on error */
 ZEND_FUNCTION(set_error_handler)
@@ -1555,7 +1553,6 @@ ZEND_FUNCTION(set_error_handler)
 }
 /* }}} */
 
-
 /* {{{ proto void restore_error_handler(void)
    Restores the previously defined error handler function */
 ZEND_FUNCTION(restore_error_handler)
@@ -1578,7 +1575,6 @@ ZEND_FUNCTION(restore_error_handler)
 }
 /* }}} */
 
-
 /* {{{ proto string set_exception_handler(callable exception_handler)
    Sets a user-defined exception handler function.  Returns the previously defined exception handler, or false on error */
 ZEND_FUNCTION(set_exception_handler)
@@ -1623,7 +1619,6 @@ ZEND_FUNCTION(set_exception_handler)
 }
 /* }}} */
 
-
 /* {{{ proto void restore_exception_handler(void)
    Restores the previously defined exception handler function */
 ZEND_FUNCTION(restore_exception_handler)
@@ -1640,73 +1635,76 @@ ZEND_FUNCTION(restore_exception_handler)
 }
 /* }}} */
 
-
-static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
 {
 	zval *array = va_arg(args, zval *);
 	zend_uint mask = va_arg(args, zend_uint);
 	zend_uint comply = va_arg(args, zend_uint);
+    zend_uint user_only = va_arg(args, zend_uint);
 	zend_uint comply_mask = (comply)? mask:0;
 	zend_class_entry *ce  = *pce;
 
-	if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0)
-		&& (comply_mask == (ce->ce_flags & mask))) {
-		add_next_index_stringl(array, ce->name, ce->name_length, 1);
-	}
+    if ((hash_key->arKey[0]!=0) && (comply_mask == (ce->ce_flags & mask))) {
+        if (user_only && ce->type != ZEND_USER_CLASS) {
+            return ZEND_HASH_APPLY_KEEP;
+        } 
+        add_next_index_stringl(array, hash_key->arKey, hash_key->nKeyLength - 1, 1);
+    }
 	return ZEND_HASH_APPLY_KEEP;
-}
+} /* }}} */
 
-/* {{{ proto array get_declared_traits()
+/* {{{ proto array get_declared_traits(bool $user_only = FALSE)
    Returns an array of all declared traits. */
 ZEND_FUNCTION(get_declared_traits)
 {
 	zend_uint mask = ZEND_ACC_TRAIT;
 	zend_uint comply = 1;
+    zend_uint user_only = 0;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &user_only) == FAILURE) {
 		return;
 	}
 
 	array_init(return_value);
-	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply);
+	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 4, return_value, mask, comply, user_only);
 }
 /* }}} */
 
-
-/* {{{ proto array get_declared_classes()
+/* {{{ proto array get_declared_classes(bool $user_only = FALSE)
    Returns an array of all declared classes. */
 ZEND_FUNCTION(get_declared_classes)
 {
 	zend_uint mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
 	zend_uint comply = 0;
+    zend_uint user_only = 0;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &user_only) == FAILURE) {
 		return;
 	}
 
 	array_init(return_value);
-	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply);
+	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 4, return_value, mask, comply, user_only);
 }
 /* }}} */
 
-/* {{{ proto array get_declared_interfaces()
+/* {{{ proto array get_declared_interfaces(bool $user_only = FALSE)
    Returns an array of all declared interfaces. */
 ZEND_FUNCTION(get_declared_interfaces)
 {
 	zend_uint mask = ZEND_ACC_INTERFACE;
 	zend_uint comply = 1;
+    zend_uint user_only = 0;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &user_only) == FAILURE) {
 		return;
 	}
 
 	array_init(return_value);
-	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply);
+	zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 4, return_value, mask, comply, user_only);
 }
 /* }}} */
 
-
-static int copy_function_name(zend_function *func TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+static int copy_function_name(zend_function *func TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
 {
 	zval *internal_ar = va_arg(args, zval *),
 	     *user_ar     = va_arg(args, zval *);
@@ -1722,8 +1720,7 @@ static int copy_function_name(zend_function *func TSRMLS_DC, int num_args, va_li
 	}
 
 	return 0;
-}
-
+} /* }}} */
 
 /* {{{ proto array get_defined_functions(void)
    Returns an array of all defined functions */
@@ -1762,7 +1759,6 @@ ZEND_FUNCTION(get_defined_functions)
 }
 /* }}} */
 
-
 /* {{{ proto array get_defined_vars(void)
    Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
 ZEND_FUNCTION(get_defined_vars)
@@ -1778,7 +1774,6 @@ ZEND_FUNCTION(get_defined_vars)
 }
 /* }}} */
 
-
 #define LAMBDA_TEMP_FUNCNAME	"__lambda_func"
 /* {{{ proto string create_function(string args, string code)
    Creates an anonymous function, and returns its name (funny, eh?) */
@@ -1844,7 +1839,6 @@ ZEND_FUNCTION(create_function)
 }
 /* }}} */
 
-
 #if ZEND_DEBUG
 ZEND_FUNCTION(zend_test_func)
 {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 19:01:31 2024 UTC