@@ -3617,19 +3617,19 @@ static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args
3617
3617
/* if it is an abstract method, there is no collision */
3618
3618
if (other_trait_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
3619
3619
/* Make sure they are compatible */
3620
- if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
3621
- /* In case both are abstract, just check prototype, but need to do that in both directions */
3622
- if ( !zend_do_perform_implementation_check (fn , other_trait_fn TSRMLS_CC )
3623
- || !zend_do_perform_implementation_check (other_trait_fn , fn TSRMLS_CC )) {
3624
- zend_error (E_COMPILE_ERROR , "Declaration of %s must be compatible with %s" , //ZEND_FN_SCOPE_NAME(fn), fn->common.function_name, //::%s()
3625
- zend_get_function_declaration (fn TSRMLS_CC ),
3626
- zend_get_function_declaration (other_trait_fn TSRMLS_CC ));
3627
- }
3628
- }
3629
- else {
3630
- /* otherwise, do the full check */
3631
- do_inheritance_check_on_method (fn , other_trait_fn TSRMLS_CC );
3632
- }
3620
+ if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
3621
+ /* In case both are abstract, just check prototype, but need to do that in both directions */
3622
+ if ( !zend_do_perform_implementation_check (fn , other_trait_fn TSRMLS_CC )
3623
+ || !zend_do_perform_implementation_check (other_trait_fn , fn TSRMLS_CC )) {
3624
+ zend_error (E_COMPILE_ERROR , "Declaration of %s must be compatible with %s" , //ZEND_FN_SCOPE_NAME(fn), fn->common.function_name, //::%s()
3625
+ zend_get_function_declaration (fn TSRMLS_CC ),
3626
+ zend_get_function_declaration (other_trait_fn TSRMLS_CC ));
3627
+ }
3628
+ }
3629
+ else {
3630
+ /* otherwise, do the full check */
3631
+ do_inheritance_check_on_method (fn , other_trait_fn TSRMLS_CC );
3632
+ }
3633
3633
3634
3634
/* we can savely free and remove it from other table */
3635
3635
zend_function_dtor (other_trait_fn );
@@ -3639,7 +3639,7 @@ static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args
3639
3639
/* if fn is an abstract method */
3640
3640
if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
3641
3641
/* Make sure they are compatible.
3642
- Here, we already know other_trait_fn cannot be abstract, full check ok. */
3642
+ Here, we already know other_trait_fn cannot be abstract, full check ok. */
3643
3643
do_inheritance_check_on_method (other_trait_fn , fn TSRMLS_CC );
3644
3644
3645
3645
/* just mark as solved, will be added if its own trait is processed */
@@ -3856,39 +3856,39 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int
3856
3856
zend_function * existing_fn = NULL ;
3857
3857
zend_function fn_copy , * fn_copy_p ;
3858
3858
zend_function * prototype = NULL ; /* is used to determine the prototype according to the inheritance chain */
3859
-
3859
+
3860
3860
if (zend_hash_quick_find (& ce -> function_table , hash_key -> arKey , hash_key -> nKeyLength , hash_key -> h , (void * * ) & existing_fn ) == FAILURE ) {
3861
3861
add = 1 ; /* not found */
3862
3862
} else if (existing_fn -> common .scope != ce ) {
3863
3863
add = 1 ; /* or inherited from other class or interface */
3864
3864
}
3865
-
3865
+
3866
3866
if (add ) {
3867
3867
zend_function * parent_function ;
3868
3868
if (ce -> parent && zend_hash_quick_find (& ce -> parent -> function_table , hash_key -> arKey , hash_key -> nKeyLength , hash_key -> h , (void * * ) & parent_function ) != FAILURE ) {
3869
3869
prototype = parent_function ; /* ->common.fn_flags |= ZEND_ACC_ABSTRACT; */
3870
3870
3871
3871
/* we got that method in the parent class, and are going to override it,
3872
- except, if the trait is just asking to have an abstract method implemented. */
3872
+ except, if the trait is just asking to have an abstract method implemented. */
3873
3873
if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
3874
3874
/* then we clean up an skip this method */
3875
3875
zend_function_dtor (fn );
3876
3876
return ZEND_HASH_APPLY_REMOVE ;
3877
3877
}
3878
3878
}
3879
-
3879
+
3880
3880
fn -> common .scope = ce ;
3881
3881
fn -> common .prototype = prototype ;
3882
-
3882
+
3883
3883
if (prototype
3884
- && (prototype -> common .fn_flags & ZEND_ACC_IMPLEMENTED_ABSTRACT
3885
- || prototype -> common .fn_flags & ZEND_ACC_ABSTRACT )) {
3886
- fn -> common .fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT ;
3887
- } else if (fn -> common .fn_flags & ZEND_ACC_IMPLEMENTED_ABSTRACT ) {
3888
- /* remove ZEND_ACC_IMPLEMENTED_ABSTRACT flag, think it shouldn't be copied to class */
3889
- fn -> common .fn_flags = fn -> common .fn_flags - ZEND_ACC_IMPLEMENTED_ABSTRACT ;
3890
- }
3891
-
3884
+ && (prototype -> common .fn_flags & ZEND_ACC_IMPLEMENTED_ABSTRACT
3885
+ || prototype -> common .fn_flags & ZEND_ACC_ABSTRACT )) {
3886
+ fn -> common .fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT ;
3887
+ } else if (fn -> common .fn_flags & ZEND_ACC_IMPLEMENTED_ABSTRACT ) {
3888
+ /* remove ZEND_ACC_IMPLEMENTED_ABSTRACT flag, think it shouldn't be copied to class */
3889
+ fn -> common .fn_flags = fn -> common .fn_flags - ZEND_ACC_IMPLEMENTED_ABSTRACT ;
3890
+ }
3891
+
3892
3892
/* check whether the trait method fullfills the inheritance requirements */
3893
3893
if (prototype ) {
3894
3894
do_inheritance_check_on_method (fn , prototype TSRMLS_CC );
@@ -3919,18 +3919,18 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int
3919
3919
}
3920
3920
fn_copy = * fn ;
3921
3921
zend_traits_duplicate_function (& fn_copy , ce , estrdup (fn -> common .function_name ) TSRMLS_CC );
3922
-
3922
+
3923
3923
if (zend_hash_quick_update (& ce -> function_table , hash_key -> arKey , hash_key -> nKeyLength , hash_key -> h , & fn_copy , sizeof (zend_function ), (void * * )& fn_copy_p )== FAILURE ) {
3924
3924
zend_error (E_COMPILE_ERROR , "Trait method %s has not been applied, because failure occured during updating class method table" , hash_key -> arKey );
3925
3925
}
3926
-
3926
+
3927
3927
zend_add_magic_methods (ce , hash_key -> arKey , hash_key -> nKeyLength , fn_copy_p TSRMLS_CC );
3928
-
3928
+
3929
3929
zend_function_dtor (fn );
3930
3930
} else {
3931
3931
zend_function_dtor (fn );
3932
3932
}
3933
-
3933
+
3934
3934
return ZEND_HASH_APPLY_REMOVE ;
3935
3935
}
3936
3936
/* }}} */
@@ -3946,12 +3946,12 @@ static int zend_traits_copy_functions(zend_function *fn TSRMLS_DC, int num_args,
3946
3946
zend_function fn_copy ;
3947
3947
void * dummy ;
3948
3948
size_t i = 0 ;
3949
-
3949
+
3950
3950
target = va_arg (args , HashTable * );
3951
3951
target_ce = va_arg (args , zend_class_entry * );
3952
3952
aliases = va_arg (args , zend_trait_alias * * );
3953
3953
exclude_table = va_arg (args , HashTable * );
3954
-
3954
+
3955
3955
fnname_len = strlen (fn -> common .function_name );
3956
3956
3957
3957
/* apply aliases which are qualified with a class name, there should not be any ambiguity */
0 commit comments