summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/bug55137.phpt26
-rw-r--r--Zend/zend_compile.c2
2 files changed, 28 insertions, 0 deletions
diff --git a/Zend/tests/bug55137.phpt b/Zend/tests/bug55137.phpt
new file mode 100644
index 0000000000..4a4e6e61a2
--- /dev/null
+++ b/Zend/tests/bug55137.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #55137 (Changing trait static method visibility)
+--FILE--
+<?php
+
+trait A {
+ protected static function foo() { echo "abc\n"; }
+ private static function bar() { echo "def\n"; }
+}
+
+
+class B {
+ use A {
+ A::foo as public;
+ A::bar as public baz;
+ }
+}
+
+B::foo();
+B::baz();
+
+
+?>
+--EXPECT--
+abc
+def
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 5f9cef311b..f3b6b77718 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3661,6 +3661,7 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args,
if (!(aliases[i]->modifiers & ZEND_ACC_PPP_MASK)) {
fn_copy.common.fn_flags |= ZEND_ACC_PUBLIC;
}
+ fn_copy.common.fn_flags |= fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK);
}
lcname_len = aliases[i]->alias_len;
@@ -3700,6 +3701,7 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args,
if (!(aliases[i]->modifiers & ZEND_ACC_PPP_MASK)) {
fn_copy.common.fn_flags |= ZEND_ACC_PUBLIC;
}
+ fn_copy.common.fn_flags |= fn->common.fn_flags ^ (fn->common.fn_flags & ZEND_ACC_PPP_MASK);
}
}
i++;