summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJohannes Schlüter <johannes@php.net>2007-04-12 18:39:46 +0000
committerJohannes Schlüter <johannes@php.net>2007-04-12 18:39:46 +0000
commitbbcd8c5b693e84483ee15bde2c683c8e6ee8c875 (patch)
treec119de44619cd22be0815d60ccd7b8218222ff84 /ext
parent9f2022743ba606522b458fc9a98141ae10b81db7 (diff)
downloadphp-git-bbcd8c5b693e84483ee15bde2c683c8e6ee8c875.tar.gz
- Fix bug #41061 ("visibility error" in ReflectionFunction::export())
Diffstat (limited to 'ext')
-rw-r--r--ext/reflection/php_reflection.c34
-rwxr-xr-xext/reflection/tests/bug41061.phpt30
2 files changed, 49 insertions, 15 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index f974d53f4c..258f8e5e14 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -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
index 0000000000..977828ef65
--- /dev/null
+++ b/ext/reflection/tests/bug41061.phpt
@@ -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===