Browse Source
63911: Compare opcodes of the op_array to determine different functions
pull/2852/merge
Pedro Magalhães
8 years ago
committed by
krakjoe
No known key found for this signature in database
GPG Key ID: F9BA0ADA31CBD89E
3 changed files with
33 additions and
0 deletions
-
NEWS
-
Zend/tests/traits/bug63911.phpt
-
Zend/zend_inheritance.c
|
|
|
@ -16,6 +16,8 @@ PHP NEWS |
|
|
|
files). (petk) |
|
|
|
. Fixed bug #74922 (Composed class has fatal error with duplicate, equal const |
|
|
|
properties). (pmmaga) |
|
|
|
. Fixed bug #63911 (identical trait methods raise errors during composition). |
|
|
|
(pmmaga) |
|
|
|
|
|
|
|
- BCMath: |
|
|
|
. Fixed bug #66364 (BCMath bcmul ignores scale parameter). (cmb) |
|
|
|
|
|
|
|
@ -0,0 +1,26 @@ |
|
|
|
--TEST-- |
|
|
|
Bug #63911 (Ignore conflicting trait methods originationg from identical sub traits) |
|
|
|
--FILE-- |
|
|
|
<?php |
|
|
|
trait A |
|
|
|
{ |
|
|
|
public function a(){ |
|
|
|
echo 'Done'; |
|
|
|
} |
|
|
|
} |
|
|
|
trait B |
|
|
|
{ |
|
|
|
use A; |
|
|
|
} |
|
|
|
trait C |
|
|
|
{ |
|
|
|
use A; |
|
|
|
} |
|
|
|
class D |
|
|
|
{ |
|
|
|
use B, C; |
|
|
|
} |
|
|
|
|
|
|
|
(new D)->a(); |
|
|
|
--EXPECT-- |
|
|
|
Done |
|
|
|
@ -1165,6 +1165,11 @@ 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) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (existing_fn->common.scope == ce) { |
|
|
|
/* members from the current class override trait methods */ |
|
|
|
/* use temporary *overriden HashTable to detect hidden conflict */ |
|
|
|
|