Hello,
I've changed get_declared_classes behaviour a bit in order to add
namespaces support (NS::class format). See attached patch.

Currently, due to what seems to me as a bug, it outputs every user-defined 
class (inside a namespace, that is) twice. I checked, and EG(class_table) 
seems to contain each namespace entry twice. This can be workedaround with 
a little hack, but i guess it should be fixed.

 --
Tal Peer
[EMAIL PROTECTED]
Index: zend_builtin_functions.c
===================================================================
RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v
retrieving revision 1.175
diff -u -r1.175 zend_builtin_functions.c
--- zend_builtin_functions.c    5 Mar 2003 11:14:41 -0000       1.175
+++ zend_builtin_functions.c    24 Mar 2003 16:37:57 -0000
@@ -1044,6 +1044,17 @@
 }
 /* }}} */
 
+static int copy_class_name_from_namespace(zend_class_entry **pce, zval *array)
+{
+       zend_class_entry *ce = *pce;
+       char *fullname = do_alloca(ce->ns->name_length + ce->name_length + 3);
+       
+       zend_sprintf(fullname, "%s::%s", ce->ns->name, ce->name);
+       add_next_index_stringl(array, fullname, ce->ns->name_length + ce->name_length 
+ 3, 1);
+       free_alloca(fullname);
+       
+       return 0;
+}
 
 static int copy_class_name(zend_class_entry **pce, int num_args, va_list args, 
zend_hash_key *hash_key)
 {
@@ -1051,8 +1062,13 @@
        zend_class_entry *ce  = *pce;
 
        if (hash_key->nKeyLength==0 || hash_key->arKey[0]!=0) {
-               add_next_index_stringl(array, ce->name, ce->name_length, 1);
+               if (ce->type == ZEND_NAMESPACE) {
+                       zend_hash_apply_with_argument(&ce->class_table, 
(apply_func_arg_t) copy_class_name_from_namespace, array TSRMLS_CC);
+               } else {
+                       add_next_index_stringl(array, ce->name, ce->name_length+1, 1);
+               }
        }
+
        return 0;
 }
 
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to