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