@@ -489,17 +489,6 @@ static inheritance_status zend_do_perform_implementation_check(
489
489
}
490
490
/* }}} */
491
491
492
- static inheritance_status perform_delayable_implementation_check (
493
- zend_string * * unresolved_class , zend_class_entry * ce ,
494
- const zend_function * fe , const zend_function * proto , zend_bool always_error ) {
495
- inheritance_status status = zend_do_perform_implementation_check (
496
- unresolved_class , fe , proto );
497
- if (status == INHERITANCE_UNRESOLVED ) {
498
- add_compatibility_obligation (ce , fe , proto , always_error );
499
- }
500
- return status ;
501
- }
502
-
503
492
static ZEND_COLD void zend_append_type_hint (smart_str * str , const zend_function * fptr , zend_arg_info * arg_info , int return_hint ) /* {{{ */
504
493
{
505
494
@@ -706,12 +695,33 @@ static void ZEND_COLD emit_incompatible_method_error_or_warning(
706
695
error_level , error_verb , child , parent , status , unresolved_class );
707
696
}
708
697
698
+ static void perform_delayable_implementation_check (
699
+ zend_class_entry * ce , const zend_function * fe ,
700
+ const zend_function * proto , zend_bool always_error )
701
+ {
702
+ zend_string * unresolved_class ;
703
+ inheritance_status status = zend_do_perform_implementation_check (
704
+ & unresolved_class , fe , proto );
705
+
706
+ if (UNEXPECTED (status != INHERITANCE_SUCCESS )) {
707
+ if (EXPECTED (status == INHERITANCE_UNRESOLVED )) {
708
+ add_compatibility_obligation (ce , fe , proto , always_error );
709
+ } else if (status == INHERITANCE_ERROR ) {
710
+ if (always_error ) {
711
+ emit_incompatible_method_error (
712
+ E_COMPILE_ERROR , "must" , fe , proto , status , unresolved_class );
713
+ } else {
714
+ emit_incompatible_method_error_or_warning (
715
+ fe , proto , status , unresolved_class , always_error );
716
+ }
717
+ }
718
+ }
719
+ }
720
+
709
721
static void do_inheritance_check_on_method (zend_function * child , zend_function * parent , zend_class_entry * ce , zval * child_zv ) /* {{{ */
710
722
{
711
723
uint32_t child_flags ;
712
724
uint32_t parent_flags = parent -> common .fn_flags ;
713
- inheritance_status status ;
714
- zend_string * unresolved_class ;
715
725
716
726
if (UNEXPECTED (parent_flags & ZEND_ACC_FINAL )) {
717
727
zend_error_at_noreturn (E_COMPILE_ERROR , NULL , func_lineno (child ),
@@ -790,12 +800,8 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
790
800
ZEND_FN_SCOPE_NAME (child ), ZSTR_VAL (child -> common .function_name ), zend_visibility_string (parent_flags ), ZEND_FN_SCOPE_NAME (parent ), (parent_flags & ZEND_ACC_PUBLIC ) ? "" : " or weaker" );
791
801
}
792
802
793
- status = perform_delayable_implementation_check (
794
- & unresolved_class , ce , child , parent , /*always_error*/ 0 );
795
- if (status == INHERITANCE_ERROR ) {
796
- emit_incompatible_method_error_or_warning (
797
- child , parent , status , unresolved_class , /*always_error*/ 0 );
798
- }
803
+ perform_delayable_implementation_check (
804
+ ce , child , parent , /*always_error*/ 0 );
799
805
}
800
806
} while (0 );
801
807
}
@@ -1507,8 +1513,6 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
1507
1513
{
1508
1514
zend_function * existing_fn = NULL ;
1509
1515
zend_function * new_fn ;
1510
- zend_string * unresolved_class ;
1511
- inheritance_status status ;
1512
1516
1513
1517
if ((existing_fn = zend_hash_find_ptr (& ce -> function_table , key )) != NULL ) {
1514
1518
/* if it is the same function with the same visibility and has not been assigned a class scope yet, regardless
@@ -1526,21 +1530,13 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
1526
1530
if ((existing_fn = zend_hash_find_ptr (* overridden , key )) != NULL ) {
1527
1531
if (existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1528
1532
/* Make sure the trait method is compatible with previosly declared abstract method */
1529
- status = perform_delayable_implementation_check (
1530
- & unresolved_class , ce , fn , existing_fn , /*always_error*/ 1 );
1531
- if (status == INHERITANCE_ERROR ) {
1532
- emit_incompatible_method_error (
1533
- E_COMPILE_ERROR , "must" , fn , existing_fn , status , unresolved_class );
1534
- }
1533
+ perform_delayable_implementation_check (
1534
+ ce , fn , existing_fn , /*always_error*/ 1 );
1535
1535
}
1536
1536
if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1537
1537
/* Make sure the abstract declaration is compatible with previous declaration */
1538
- status = perform_delayable_implementation_check (
1539
- & unresolved_class , ce , existing_fn , fn , /*always_error*/ 1 );
1540
- if (status == INHERITANCE_ERROR ) {
1541
- emit_incompatible_method_error (
1542
- E_COMPILE_ERROR , "must" , existing_fn , fn , status , unresolved_class );
1543
- }
1538
+ perform_delayable_implementation_check (
1539
+ ce , existing_fn , fn , /*always_error*/ 1 );
1544
1540
return ;
1545
1541
}
1546
1542
}
@@ -1553,20 +1549,12 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
1553
1549
} else if (existing_fn -> common .fn_flags & ZEND_ACC_ABSTRACT &&
1554
1550
(existing_fn -> common .scope -> ce_flags & ZEND_ACC_INTERFACE ) == 0 ) {
1555
1551
/* Make sure the trait method is compatible with previosly declared abstract method */
1556
- status = perform_delayable_implementation_check (
1557
- & unresolved_class , ce , fn , existing_fn , /*always_error*/ 1 );
1558
- if (status == INHERITANCE_ERROR ) {
1559
- emit_incompatible_method_error (
1560
- E_COMPILE_ERROR , "must" , fn , existing_fn , status , unresolved_class );
1561
- }
1552
+ perform_delayable_implementation_check (
1553
+ ce , fn , existing_fn , /*always_error*/ 1 );
1562
1554
} else if (fn -> common .fn_flags & ZEND_ACC_ABSTRACT ) {
1563
1555
/* Make sure the abstract declaration is compatible with previous declaration */
1564
- status = perform_delayable_implementation_check (
1565
- & unresolved_class , ce , existing_fn , fn , /*always_error*/ 1 );
1566
- if (status == INHERITANCE_ERROR ) {
1567
- emit_incompatible_method_error (
1568
- E_COMPILE_ERROR , "must" , existing_fn , fn , status , unresolved_class );
1569
- }
1556
+ perform_delayable_implementation_check (
1557
+ ce , existing_fn , fn , /*always_error*/ 1 );
1570
1558
return ;
1571
1559
} else if (UNEXPECTED (existing_fn -> common .scope -> ce_flags & ZEND_ACC_TRAIT )) {
1572
1560
/* two traits can't define the same non-abstract method */
0 commit comments