]> granicus.if.org Git - php/commitdiff
- MFH Add ReflectionClass::getInterfaceNames()
authorMarcus Boerger <helly@php.net>
Wed, 7 Jun 2006 09:26:11 +0000 (09:26 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 7 Jun 2006 09:26:11 +0000 (09:26 +0000)
ext/reflection/php_reflection.c

index 14586f0090397522d29435d98569c887a355bf3b..6a2eff02c5aa94610381382576af3066ff2c136e 100644 (file)
@@ -3416,6 +3416,26 @@ ZEND_METHOD(reflection_class, getInterfaces)
 }
 /* }}} */
 
+/* {{{ proto public String[] ReflectionClass::getInterfaceNames()
+   Returns an array of names of interfaces this class implements */
+ZEND_METHOD(reflection_class, getInterfaceNames)
+{
+       reflection_object *intern;
+       zend_class_entry *ce;
+       zend_uint i;
+
+       METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0);
+       GET_REFLECTION_OBJECT_PTR(ce);
+
+       /* Return an empty array if this class implements no interfaces */
+       array_init(return_value);
+
+       for (i=0; i < ce->num_interfaces; i++) {
+               add_next_index_stringl(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length, 1);
+       }
+}
+/* }}} */
+
 /* {{{ proto public ReflectionClass ReflectionClass::getParentClass()
    Returns the class' parent class, or, if none exists, FALSE */
 ZEND_METHOD(reflection_class, getParentClass)
@@ -4290,6 +4310,7 @@ static zend_function_entry reflection_class_functions[] = {
        ZEND_ME(reflection_class, getConstants, NULL, 0)
        ZEND_ME(reflection_class, getConstant, NULL, 0)
        ZEND_ME(reflection_class, getInterfaces, NULL, 0)
+       ZEND_ME(reflection_class, getInterfaceNames, NULL, 0)
        ZEND_ME(reflection_class, isInterface, NULL, 0)
        ZEND_ME(reflection_class, isAbstract, NULL, 0)
        ZEND_ME(reflection_class, isFinal, NULL, 0)