Skip to content

Commit 49f53a9

Browse files
committed
Collapse branches together
1 parent 062d557 commit 49f53a9

File tree

1 file changed

+8
-35
lines changed

1 file changed

+8
-35
lines changed

Zend/zend_inheritance.c

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -657,57 +657,30 @@ static inheritance_status zend_perform_covariant_type_check(
657657
all_success = false;
658658
}
659659
} ZEND_TYPE_FOREACH_END();
660-
} else if (ZEND_TYPE_IS_INTERSECTION(proto_type)) {
661-
/* Here each member of the child union must be a subtype of the intersection
662-
* Note: the union can be a single element */
663-
660+
} else {
664661
/* First try to check whether we can succeed without resolving anything */
665662
ZEND_TYPE_FOREACH(fe_type, single_type) {
666663
inheritance_status status;
667664
zend_string *fe_class_name;
668665
zend_class_entry *fe_ce = NULL;
669666

670667
if (ZEND_TYPE_HAS_NAME(*single_type)) {
671-
fe_class_name = resolve_class_name(proto_scope, ZEND_TYPE_NAME(*single_type));
668+
fe_class_name = resolve_class_name(fe_scope, ZEND_TYPE_NAME(*single_type));
672669
} else if (ZEND_TYPE_HAS_CE(*single_type)) {
673670
fe_ce = ZEND_TYPE_CE(*single_type);
674671
fe_class_name = fe_ce->name;
675672
} else {
676-
/* standard type */
677-
ZEND_ASSERT(0 && "This shouldn't happen yet");
678673
continue;
679674
}
680675

681-
status = zend_is_single_type_subtype_intersection(fe_scope,
676+
if (UNEXPECTED(ZEND_TYPE_IS_INTERSECTION(proto_type))) {
677+
status = zend_is_single_type_subtype_intersection(fe_scope,
678+
fe_class_name, fe_ce, proto_scope, proto_type,
679+
/* register_unresolved */ false);
680+
} else {
681+
status = zend_perform_covariant_class_type_check(fe_scope,
682682
fe_class_name, fe_ce, proto_scope, proto_type,
683683
/* register_unresolved */ false);
684-
685-
if (status == INHERITANCE_ERROR) {
686-
return INHERITANCE_ERROR;
687-
}
688-
if (status != INHERITANCE_SUCCESS) {
689-
all_success = false;
690-
}
691-
} ZEND_TYPE_FOREACH_END();
692-
}
693-
/* Only union or single types both in parent and child */
694-
else {
695-
/* First try to check whether we can succeed without resolving anything */
696-
ZEND_TYPE_FOREACH(fe_type, single_type) {
697-
inheritance_status status;
698-
if (ZEND_TYPE_HAS_NAME(*single_type)) {
699-
zend_string *fe_class_name =
700-
resolve_class_name(fe_scope, ZEND_TYPE_NAME(*single_type));
701-
status = zend_perform_covariant_class_type_check(
702-
fe_scope, fe_class_name, NULL,
703-
proto_scope, proto_type, /* register_unresolved */ 0);
704-
} else if (ZEND_TYPE_HAS_CE(*single_type)) {
705-
zend_class_entry *fe_ce = ZEND_TYPE_CE(*single_type);
706-
status = zend_perform_covariant_class_type_check(
707-
fe_scope, fe_ce->name, fe_ce,
708-
proto_scope, proto_type, /* register_unresolved */ 0);
709-
} else {
710-
continue;
711684
}
712685

713686
if (status == INHERITANCE_ERROR) {

0 commit comments

Comments
 (0)