@@ -609,57 +609,30 @@ static inheritance_status zend_perform_covariant_type_check(
609
609
all_success = false;
610
610
}
611
611
} ZEND_TYPE_FOREACH_END ();
612
- } else if (ZEND_TYPE_IS_INTERSECTION (proto_type )) {
613
- /* Here each member of the child union must be a subtype of the intersection
614
- * Note: the union can be a single element */
615
-
612
+ } else {
616
613
/* First try to check whether we can succeed without resolving anything */
617
614
ZEND_TYPE_FOREACH (fe_type , single_type ) {
618
615
inheritance_status status ;
619
616
zend_string * fe_class_name ;
620
617
zend_class_entry * fe_ce = NULL ;
621
618
622
619
if (ZEND_TYPE_HAS_NAME (* single_type )) {
623
- fe_class_name = resolve_class_name (proto_scope , ZEND_TYPE_NAME (* single_type ));
620
+ fe_class_name = resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
624
621
} else if (ZEND_TYPE_HAS_CE (* single_type )) {
625
622
fe_ce = ZEND_TYPE_CE (* single_type );
626
623
fe_class_name = fe_ce -> name ;
627
624
} else {
628
- /* standard type */
629
- ZEND_ASSERT (0 && "This shouldn't happen yet" );
630
625
continue ;
631
626
}
632
627
633
- status = zend_is_single_type_subtype_intersection (fe_scope ,
628
+ if (UNEXPECTED (ZEND_TYPE_IS_INTERSECTION (proto_type ))) {
629
+ status = zend_is_single_type_subtype_intersection (fe_scope ,
630
+ fe_class_name , fe_ce , proto_scope , proto_type ,
631
+ /* register_unresolved */ false);
632
+ } else {
633
+ status = zend_perform_covariant_class_type_check (fe_scope ,
634
634
fe_class_name , fe_ce , proto_scope , proto_type ,
635
635
/* register_unresolved */ false);
636
-
637
- if (status == INHERITANCE_ERROR ) {
638
- return INHERITANCE_ERROR ;
639
- }
640
- if (status != INHERITANCE_SUCCESS ) {
641
- all_success = false;
642
- }
643
- } ZEND_TYPE_FOREACH_END ();
644
- }
645
- /* Only union or single types both in parent and child */
646
- else {
647
- /* First try to check whether we can succeed without resolving anything */
648
- ZEND_TYPE_FOREACH (fe_type , single_type ) {
649
- inheritance_status status ;
650
- if (ZEND_TYPE_HAS_NAME (* single_type )) {
651
- zend_string * fe_class_name =
652
- resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
653
- status = zend_perform_covariant_class_type_check (
654
- fe_scope , fe_class_name , NULL ,
655
- proto_scope , proto_type , /* register_unresolved */ 0 );
656
- } else if (ZEND_TYPE_HAS_CE (* single_type )) {
657
- zend_class_entry * fe_ce = ZEND_TYPE_CE (* single_type );
658
- status = zend_perform_covariant_class_type_check (
659
- fe_scope , fe_ce -> name , fe_ce ,
660
- proto_scope , proto_type , /* register_unresolved */ 0 );
661
- } else {
662
- continue ;
663
636
}
664
637
665
638
if (status == INHERITANCE_ERROR ) {
@@ -677,21 +650,30 @@ static inheritance_status zend_perform_covariant_type_check(
677
650
}
678
651
679
652
/* Register all classes that may have to be resolved */
680
- if (ZEND_TYPE_IS_INTERSECTION (proto_type )) {
653
+ if (ZEND_TYPE_IS_INTERSECTION (fe_type )) {
681
654
// TODO Register intersection type classes
682
655
} else {
683
656
ZEND_TYPE_FOREACH (fe_type , single_type ) {
657
+ zend_string * fe_class_name ;
658
+ zend_class_entry * fe_ce = NULL ;
659
+
684
660
if (ZEND_TYPE_HAS_NAME (* single_type )) {
685
- zend_string * fe_class_name =
686
- resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
687
- zend_perform_covariant_class_type_check (
688
- fe_scope , fe_class_name , NULL ,
689
- proto_scope , proto_type , /* register_unresolved */ 1 );
661
+ fe_class_name = resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
690
662
} else if (ZEND_TYPE_HAS_CE (* single_type )) {
691
- zend_class_entry * fe_ce = ZEND_TYPE_CE (* single_type );
692
- zend_perform_covariant_class_type_check (
693
- fe_scope , fe_ce -> name , fe_ce ,
694
- proto_scope , proto_type , /* register_unresolved */ 1 );
663
+ fe_ce = ZEND_TYPE_CE (* single_type );
664
+ fe_class_name = fe_ce -> name ;
665
+ } else {
666
+ continue ;
667
+ }
668
+
669
+ if (UNEXPECTED (ZEND_TYPE_IS_INTERSECTION (proto_type ))) {
670
+ zend_is_single_type_subtype_intersection (fe_scope ,
671
+ fe_class_name , fe_ce , proto_scope , proto_type ,
672
+ /* register_unresolved */ true);
673
+ } else {
674
+ zend_perform_covariant_class_type_check (fe_scope ,
675
+ fe_class_name , fe_ce , proto_scope , proto_type ,
676
+ /* register_unresolved */ true);
695
677
}
696
678
} ZEND_TYPE_FOREACH_END ();
697
679
}
0 commit comments