From: Pedro Magalhães Date: Fri, 3 Aug 2018 16:30:03 +0000 (+0100) Subject: Fix #76700 - Methods with altered visibility need to be added again X-Git-Tag: php-7.4.0alpha1~2131^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97b2558b760309e8fa99f4fcf45bc56a75598892;p=php Fix #76700 - Methods with altered visibility need to be added again --- diff --git a/Zend/tests/traits/bug76700.phpt b/Zend/tests/traits/bug76700.phpt new file mode 100644 index 0000000000..5b746d5671 --- /dev/null +++ b/Zend/tests/traits/bug76700.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #76700 (false-positive "Error: Call to protected method" when using trait aliases) +--FILE-- +aa(); + +--EXPECT-- +123 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index dc55410b66..8af409f191 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1178,8 +1178,10 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s zend_function *new_fn; if ((existing_fn = zend_hash_find_ptr(&ce->function_table, key)) != NULL) { - /* if it is the same function regardless of where it is coming from, there is no conflict and we do not need to add it again */ - if (existing_fn->op_array.opcodes == fn->op_array.opcodes) { + /* if it is the same function with the same visibility regardless of where it is coming from */ + /* there is no conflict and we do not need to add it again */ + if (existing_fn->op_array.opcodes == fn->op_array.opcodes && + (existing_fn->common.fn_flags & ZEND_ACC_PPP_MASK) == (fn->common.fn_flags & ZEND_ACC_PPP_MASK)) { return; }