@@ -657,57 +657,30 @@ static inheritance_status zend_perform_covariant_type_check(
657
657
all_success = false;
658
658
}
659
659
} 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 {
664
661
/* First try to check whether we can succeed without resolving anything */
665
662
ZEND_TYPE_FOREACH (fe_type , single_type ) {
666
663
inheritance_status status ;
667
664
zend_string * fe_class_name ;
668
665
zend_class_entry * fe_ce = NULL ;
669
666
670
667
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 ));
672
669
} else if (ZEND_TYPE_HAS_CE (* single_type )) {
673
670
fe_ce = ZEND_TYPE_CE (* single_type );
674
671
fe_class_name = fe_ce -> name ;
675
672
} else {
676
- /* standard type */
677
- ZEND_ASSERT (0 && "This shouldn't happen yet" );
678
673
continue ;
679
674
}
680
675
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 ,
682
682
fe_class_name , fe_ce , proto_scope , proto_type ,
683
683
/* 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 ;
711
684
}
712
685
713
686
if (status == INHERITANCE_ERROR ) {
0 commit comments