Skip to content

Commit f256c3f

Browse files
committed
Move INHERITANCE_WARNING handling one layer up
There is only a single place where we need to convert ERROR into WARNING, don't thread it through more places than necessary.
1 parent ac18dd0 commit f256c3f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Zend/zend_inheritance.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static inheritance_status zend_perform_covariant_class_type_check(
461461

462462
static inheritance_status zend_perform_covariant_type_check(
463463
zend_class_entry *fe_scope, zend_type fe_type,
464-
zend_class_entry *proto_scope, zend_type proto_type, bool tentative) /* {{{ */
464+
zend_class_entry *proto_scope, zend_type proto_type)
465465
{
466466
ZEND_ASSERT(ZEND_TYPE_IS_SET(fe_type) && ZEND_TYPE_IS_SET(proto_type));
467467

@@ -502,7 +502,7 @@ static inheritance_status zend_perform_covariant_type_check(
502502

503503
if (added_types) {
504504
/* Otherwise adding new types is illegal */
505-
return tentative ? INHERITANCE_WARNING : INHERITANCE_ERROR;
505+
return INHERITANCE_ERROR;
506506
}
507507
}
508508

@@ -528,7 +528,7 @@ static inheritance_status zend_perform_covariant_type_check(
528528
}
529529

530530
if (status == INHERITANCE_ERROR) {
531-
return tentative ? INHERITANCE_WARNING : INHERITANCE_ERROR;
531+
return INHERITANCE_ERROR;
532532
}
533533
if (status != INHERITANCE_SUCCESS) {
534534
all_success = 0;
@@ -557,7 +557,6 @@ static inheritance_status zend_perform_covariant_type_check(
557557
} ZEND_TYPE_FOREACH_END();
558558
return INHERITANCE_UNRESOLVED;
559559
}
560-
/* }}} */
561560

562561
static inheritance_status zend_do_perform_arg_type_hint_check(
563562
zend_class_entry *fe_scope, zend_arg_info *fe_arg_info,
@@ -576,7 +575,7 @@ static inheritance_status zend_do_perform_arg_type_hint_check(
576575
/* Contravariant type check is performed as a covariant type check with swapped
577576
* argument order. */
578577
return zend_perform_covariant_type_check(
579-
proto_scope, proto_arg_info->type, fe_scope, fe_arg_info->type, 0);
578+
proto_scope, proto_arg_info->type, fe_scope, fe_arg_info->type);
580579
}
581580
/* }}} */
582581

@@ -678,15 +677,14 @@ static inheritance_status zend_do_perform_implementation_check(
678677
}
679678

680679
local_status = zend_perform_covariant_type_check(
681-
fe_scope, fe->common.arg_info[-1].type,
682-
proto_scope, proto->common.arg_info[-1].type, ZEND_ARG_TYPE_IS_TENTATIVE(&proto->common.arg_info[-1]));
680+
fe_scope, fe->common.arg_info[-1].type, proto_scope, proto->common.arg_info[-1].type);
683681

684682
if (UNEXPECTED(local_status != INHERITANCE_SUCCESS)) {
685-
if (UNEXPECTED(local_status == INHERITANCE_ERROR || local_status == INHERITANCE_WARNING)) {
686-
return local_status;
683+
if (local_status == INHERITANCE_ERROR
684+
&& ZEND_ARG_TYPE_IS_TENTATIVE(&proto->common.arg_info[-1])) {
685+
local_status = INHERITANCE_WARNING;
687686
}
688-
ZEND_ASSERT(local_status == INHERITANCE_UNRESOLVED);
689-
status = INHERITANCE_UNRESOLVED;
687+
return local_status;
690688
}
691689
}
692690

@@ -1077,9 +1075,9 @@ inheritance_status property_types_compatible(
10771075

10781076
/* Perform a covariant type check in both directions to determined invariance. */
10791077
inheritance_status status1 = zend_perform_covariant_type_check(
1080-
child_info->ce, child_info->type, parent_info->ce, parent_info->type, 0);
1078+
child_info->ce, child_info->type, parent_info->ce, parent_info->type);
10811079
inheritance_status status2 = zend_perform_covariant_type_check(
1082-
parent_info->ce, parent_info->type, child_info->ce, child_info->type, 0);
1080+
parent_info->ce, parent_info->type, child_info->ce, child_info->type);
10831081
if (status1 == INHERITANCE_SUCCESS && status2 == INHERITANCE_SUCCESS) {
10841082
return INHERITANCE_SUCCESS;
10851083
}

0 commit comments

Comments
 (0)