@@ -611,11 +611,11 @@ static inheritance_status zend_perform_covariant_type_check(
611
611
zend_type * single_type ;
612
612
bool all_success = true;
613
613
614
- /* For intersection types loop over the parent types first as a child
615
- * can add them */
616
- if ( ZEND_TYPE_IS_INTERSECTION ( fe_type )
617
- || ( ZEND_TYPE_IS_INTERSECTION ( proto_type ) && ! ZEND_TYPE_IS_UNION ( fe_type ))
618
- ) {
614
+ /* If the child type is an intersection type then we need to loop over
615
+ * the parents firstFor intersection types loop over the parent types first
616
+ * as the child can add types, however none of them can be a supertype of
617
+ * a parent type. */
618
+ if ( ZEND_TYPE_IS_INTERSECTION ( fe_type ) ) {
619
619
/* First try to check whether we can succeed without resolving anything */
620
620
ZEND_TYPE_FOREACH (proto_type , single_type ) {
621
621
inheritance_status status ;
@@ -645,13 +645,12 @@ static inheritance_status zend_perform_covariant_type_check(
645
645
all_success = false;
646
646
}
647
647
} ZEND_TYPE_FOREACH_END ();
648
- } else if (ZEND_TYPE_IS_INTERSECTION (proto_type ) && ZEND_TYPE_IS_UNION (fe_type )) {
649
- /* Here each member of the child union must be a subtype of the intersection */
648
+ } else if (ZEND_TYPE_IS_INTERSECTION (proto_type )) {
649
+ /* Here each member of the child union must be a subtype of the intersection
650
+ * Note: the union can be a single element */
650
651
651
652
/* First try to check whether we can succeed without resolving anything */
652
- zend_type_list * child_union_types = ZEND_TYPE_LIST (fe_type );
653
-
654
- ZEND_TYPE_LIST_FOREACH (child_union_types , single_type ) {
653
+ ZEND_TYPE_FOREACH (fe_type , single_type ) {
655
654
inheritance_status status ;
656
655
zend_string * fe_class_name ;
657
656
zend_class_entry * fe_ce = NULL ;
@@ -677,7 +676,7 @@ static inheritance_status zend_perform_covariant_type_check(
677
676
if (status != INHERITANCE_SUCCESS ) {
678
677
all_success = false;
679
678
}
680
- } ZEND_TYPE_LIST_FOREACH_END ();
679
+ } ZEND_TYPE_FOREACH_END ();
681
680
}
682
681
/* Only union or single types both in parent and child */
683
682
else {
0 commit comments