]> granicus.if.org Git - php/commitdiff
- Added get_declared_traits()
authorFelipe Pena <felipe@php.net>
Thu, 6 May 2010 15:18:20 +0000 (15:18 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 6 May 2010 15:18:20 +0000 (15:18 +0000)
UPGRADING
Zend/zend_builtin_functions.c

index 5b19f5250d22d6541efd15bba7fedee7376a0735..8e51c8f649b219f623ef6877685e2fe57297c0db 100755 (executable)
--- a/UPGRADING
+++ b/UPGRADING
@@ -216,6 +216,7 @@ UPGRADE NOTES - PHP X.Y
      f. New global constants
 
        - Core:
+         - get_declared_traits()
 
      g. New classes
 
index 5686fb94a6b85d468c21bdeefd62872e658661f2..0a675bba425db126441efad65245ef2331316f86 100644 (file)
@@ -69,6 +69,7 @@ static ZEND_FUNCTION(restore_error_handler);
 static ZEND_FUNCTION(set_exception_handler);
 static ZEND_FUNCTION(restore_exception_handler);
 static ZEND_FUNCTION(get_declared_classes);
+static ZEND_FUNCTION(get_declared_traits);
 static ZEND_FUNCTION(get_declared_interfaces);
 static ZEND_FUNCTION(get_defined_functions);
 static ZEND_FUNCTION(get_defined_vars);
@@ -261,6 +262,7 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
        ZEND_FE(set_exception_handler,          arginfo_set_exception_handler)
        ZEND_FE(restore_exception_handler,      arginfo_zend__void)
        ZEND_FE(get_declared_classes,           arginfo_zend__void)
+       ZEND_FE(get_declared_traits,            arginfo_zend__void)
        ZEND_FE(get_declared_interfaces,        arginfo_zend__void)
        ZEND_FE(get_defined_functions,          arginfo_zend__void)
        ZEND_FE(get_defined_vars,                       arginfo_zend__void)
@@ -1564,12 +1566,28 @@ static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int nu
        return ZEND_HASH_APPLY_KEEP;
 }
 
+/* {{{ proto array get_declared_traits()
+   Returns an array of all declared traits. */
+ZEND_FUNCTION(get_declared_traits)
+{
+       zend_uint mask = ZEND_ACC_TRAIT;
+       zend_uint comply = 1;
+
+       if (zend_parse_parameters_none() == 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);
+}
+/* }}} */
+
 
 /* {{{ proto array get_declared_classes()
    Returns an array of all declared classes. */
 ZEND_FUNCTION(get_declared_classes)
 {
-       zend_uint mask = ZEND_ACC_INTERFACE;
+       zend_uint mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT & ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
        zend_uint comply = 0;
 
        if (zend_parse_parameters_none() == FAILURE) {