]> granicus.if.org Git - php/commitdiff
- Fix bug #41061 ("visibility error" in ReflectionFunction::export())
authorJohannes Schlüter <johannes@php.net>
Thu, 12 Apr 2007 18:39:46 +0000 (18:39 +0000)
committerJohannes Schlüter <johannes@php.net>
Thu, 12 Apr 2007 18:39:46 +0000 (18:39 +0000)
NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug41061.phpt [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 287a3b2d07cc8fed2ffaa658cd4b4dcd9a9209c8..67da13e1996bc2f957ea4c0c765ed6667b08fe5c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Apr 2007, PHP 5.2.2RC2
 - Fixed bug #41063 (chdir doesn't like root paths). (Dmitry)
+- Fixed bug #41061 ("visibility error" in ReflectionFunction::export()).
+  (Johannes)
 - Fixed bug #40861 (strtotime() doesn't handle double negative relative time
   units correctly). (Derick)
 
index f974d53f4cf08e3361aa2e66667eecf14bb18a4c..258f8e5e14bb34fe7c0f8708e05eba987b36e60e 100644 (file)
@@ -747,23 +747,27 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
                string_printf(str, "static ");
        }
 
-       /* These are mutually exclusive */
-       switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) {
-               case ZEND_ACC_PUBLIC:
-                       string_printf(str, "public ");
-                       break;
-               case ZEND_ACC_PRIVATE:
-                       string_printf(str, "private ");
-                       break;
-               case ZEND_ACC_PROTECTED:
-                       string_printf(str, "protected ");
-                       break;
-               default:
-                   string_printf(str, "<visibility error> ");
-                   break;
+       if (fptr->common.scope) {
+               /* These are mutually exclusive */
+               switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) {
+                       case ZEND_ACC_PUBLIC:
+                               string_printf(str, "public ");
+                               break;
+                       case ZEND_ACC_PRIVATE:
+                               string_printf(str, "private ");
+                               break;
+                       case ZEND_ACC_PROTECTED:
+                               string_printf(str, "protected ");
+                               break;
+                       default:
+                           string_printf(str, "<visibility error> ");
+                           break;
+               }
+               string_printf(str, "method ");
+       } else {
+               string_printf(str, "function ");
        }
 
-       string_printf(str, fptr->common.scope ? "method " : "function ");
        if (fptr->op_array.return_reference) {
                string_printf(str, "&");
        }
diff --git a/ext/reflection/tests/bug41061.phpt b/ext/reflection/tests/bug41061.phpt
new file mode 100755 (executable)
index 0000000..977828e
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Reflection Bug #41061 ("visibility error" in ReflectionFunction::export())
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--FILE--
+<?php
+
+function foo() {
+}
+class bar {
+    private function foo() {
+    }
+}
+
+Reflection::export(new ReflectionFunction('foo'));
+Reflection::export(new ReflectionMethod('bar', 'foo'));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Function [ <user> function foo ] {
+  @@ %sbug41061.php 3 - 4
+}
+
+Method [ <user> private method foo ] {
+  @@ %sbug41061.php 7 - 8
+}
+
+===DONE===