1
0
mirror of https://github.com/php/php-src.git synced 2026-04-15 03:51:07 +02:00

Fix #76700 - Methods with altered visibility need to be added again

This commit is contained in:
Pedro Magalhães
2018-08-03 17:30:03 +01:00
parent 2ea7222440
commit 97b2558b76
2 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
--TEST--
Bug #76700 (false-positive "Error: Call to protected method" when using trait aliases)
--FILE--
<?php
trait T1
{
protected function aa() { echo 123; }
}
trait T2
{
use T1 {
aa as public;
}
}
class A
{
use T1;
}
class B extends A
{
use T2;
}
$b = new B();
$b->aa();
--EXPECT--
123

View File

@@ -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;
}