]> granicus.if.org Git - php/commitdiff
- Fixed bug #45571 (ReflectionClass::export() shows superclasses' private static...
authorFelipe Pena <felipe@php.net>
Sun, 20 Jul 2008 16:51:28 +0000 (16:51 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 20 Jul 2008 16:51:28 +0000 (16:51 +0000)
  patch by Robin Fernandes

ext/reflection/php_reflection.c
ext/reflection/tests/bug45571.phpt [new file with mode: 0644]

index f99e009830dde83b462e5670c3c68cb681bd452e..601850fdb716a0dfed5d8f13315d2dfebc2c5052 100644 (file)
@@ -417,7 +417,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
        
        /* Static methods */
        if (&ce->function_table) {
-               /* counting static properties */                
+               /* counting static methods */           
                count = zend_hash_num_elements(&ce->function_table);
                if (count > 0) {
                        HashPosition pos;
@@ -426,14 +426,15 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
                        zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
 
                        while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
-                               if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
+                               if (mptr->common.fn_flags & ZEND_ACC_STATIC
+                                       && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) {
                                        count_static_funcs++;
                                }
                                zend_hash_move_forward_ex(&ce->function_table, &pos);
                        }
                }
 
-               /* static properties */         
+               /* static methods */            
                string_printf(str, "\n%s  - Static methods [%d] {", indent, count_static_funcs);
                if (count_static_funcs > 0) {
                        HashPosition pos;
@@ -442,7 +443,8 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
                        zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
 
                        while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
-                               if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
+                               if (mptr->common.fn_flags & ZEND_ACC_STATIC
+                                       && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) {
                                        string_printf(str, "\n");
                                        _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC);
                                }
diff --git a/ext/reflection/tests/bug45571.phpt b/ext/reflection/tests/bug45571.phpt
new file mode 100644 (file)
index 0000000..4df542e
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Bug #45571 (ReflectionClass::export() shows superclasses' private static methods.)
+--FILE--
+<?php
+
+Class A {
+       static private $a       = 0;
+       static protected $b = 1;
+       static public $c        = 2;
+       
+       private function f() {}
+       private static function sf() {}
+}
+
+Class C extends A { }
+
+ReflectionClass::export("C");
+
+?>
+--EXPECTF--
+Class [ <user> class C extends A ] {
+  @@ %s 12-12
+
+  - Constants [0] {
+  }
+
+  - Static properties [2] {
+    Property [ protected static $b ]
+    Property [ public static $c ]
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [0] {
+  }
+}