@@ -1949,6 +1949,10 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
1949
1949
zend_function * new_fn ;
1950
1950
bool check_inheritance = false;
1951
1951
1952
+ if ((fn -> common .fn_flags & (ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )) == (ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )) {
1953
+ zend_error (E_COMPILE_WARNING , "Private methods cannot be final as they are never overridden by other classes" );
1954
+ }
1955
+
1952
1956
if ((existing_fn = zend_hash_find_ptr (& ce -> function_table , key )) != NULL ) {
1953
1957
/* if it is the same function with the same visibility and has not been assigned a class scope yet, regardless
1954
1958
* of where it is coming from there is no conflict and we do not need to add it again */
@@ -2048,10 +2052,10 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
2048
2052
&& zend_string_equals_ci (alias -> trait_method .method_name , fnname )
2049
2053
) {
2050
2054
fn_copy = * fn ;
2051
-
2052
- /* if it is 0, no modifiers have been changed */
2053
- if (alias -> modifiers ) {
2055
+ if (alias -> modifiers & ZEND_ACC_PPP_MASK ) {
2054
2056
fn_copy .common .fn_flags = alias -> modifiers | (fn -> common .fn_flags & ~ZEND_ACC_PPP_MASK );
2057
+ } else {
2058
+ fn_copy .common .fn_flags = alias -> modifiers | fn -> common .fn_flags ;
2055
2059
}
2056
2060
2057
2061
lcname = zend_string_tolower (alias -> alias );
@@ -2079,7 +2083,11 @@ static void zend_traits_copy_functions(zend_string *fnname, zend_function *fn, z
2079
2083
&& fn -> common .scope == aliases [i ]
2080
2084
&& zend_string_equals_ci (alias -> trait_method .method_name , fnname )
2081
2085
) {
2082
- fn_copy .common .fn_flags = alias -> modifiers | (fn -> common .fn_flags & ~ZEND_ACC_PPP_MASK );
2086
+ if (alias -> modifiers & ZEND_ACC_PPP_MASK ) {
2087
+ fn_copy .common .fn_flags = alias -> modifiers | (fn -> common .fn_flags & ~ZEND_ACC_PPP_MASK );
2088
+ } else {
2089
+ fn_copy .common .fn_flags = alias -> modifiers | fn -> common .fn_flags ;
2090
+ }
2083
2091
}
2084
2092
alias_ptr ++ ;
2085
2093
alias = * alias_ptr ;
0 commit comments