@@ -645,57 +645,30 @@ 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 )) {
649
- /* Here each member of the child union must be a subtype of the intersection
650
- * Note: the union can be a single element */
651
-
648
+ } else {
652
649
/* First try to check whether we can succeed without resolving anything */
653
650
ZEND_TYPE_FOREACH (fe_type , single_type ) {
654
651
inheritance_status status ;
655
652
zend_string * fe_class_name ;
656
653
zend_class_entry * fe_ce = NULL ;
657
654
658
655
if (ZEND_TYPE_HAS_NAME (* single_type )) {
659
- fe_class_name = resolve_class_name (proto_scope , ZEND_TYPE_NAME (* single_type ));
656
+ fe_class_name = resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
660
657
} else if (ZEND_TYPE_HAS_CE (* single_type )) {
661
658
fe_ce = ZEND_TYPE_CE (* single_type );
662
659
fe_class_name = fe_ce -> name ;
663
660
} else {
664
- /* standard type */
665
- ZEND_ASSERT (0 && "This shouldn't happen yet" );
666
661
continue ;
667
662
}
668
663
669
- status = zend_is_single_type_subtype_intersection (fe_scope ,
664
+ if (UNEXPECTED (ZEND_TYPE_IS_INTERSECTION (proto_type ))) {
665
+ status = zend_is_single_type_subtype_intersection (fe_scope ,
666
+ fe_class_name , fe_ce , proto_scope , proto_type ,
667
+ /* register_unresolved */ false);
668
+ } else {
669
+ status = zend_perform_covariant_class_type_check (fe_scope ,
670
670
fe_class_name , fe_ce , proto_scope , proto_type ,
671
671
/* register_unresolved */ false);
672
-
673
- if (status == INHERITANCE_ERROR ) {
674
- return INHERITANCE_ERROR ;
675
- }
676
- if (status != INHERITANCE_SUCCESS ) {
677
- all_success = false;
678
- }
679
- } ZEND_TYPE_FOREACH_END ();
680
- }
681
- /* Only union or single types both in parent and child */
682
- else {
683
- /* First try to check whether we can succeed without resolving anything */
684
- ZEND_TYPE_FOREACH (fe_type , single_type ) {
685
- inheritance_status status ;
686
- if (ZEND_TYPE_HAS_NAME (* single_type )) {
687
- zend_string * fe_class_name =
688
- resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
689
- status = zend_perform_covariant_class_type_check (
690
- fe_scope , fe_class_name , NULL ,
691
- proto_scope , proto_type , /* register_unresolved */ 0 );
692
- } else if (ZEND_TYPE_HAS_CE (* single_type )) {
693
- zend_class_entry * fe_ce = ZEND_TYPE_CE (* single_type );
694
- status = zend_perform_covariant_class_type_check (
695
- fe_scope , fe_ce -> name , fe_ce ,
696
- proto_scope , proto_type , /* register_unresolved */ 0 );
697
- } else {
698
- continue ;
699
672
}
700
673
701
674
if (status == INHERITANCE_ERROR ) {
@@ -713,21 +686,30 @@ static inheritance_status zend_perform_covariant_type_check(
713
686
}
714
687
715
688
/* Register all classes that may have to be resolved */
716
- if (ZEND_TYPE_IS_INTERSECTION (proto_type )) {
689
+ if (ZEND_TYPE_IS_INTERSECTION (fe_type )) {
717
690
// TODO Register intersection type classes
718
691
} else {
719
692
ZEND_TYPE_FOREACH (fe_type , single_type ) {
693
+ zend_string * fe_class_name ;
694
+ zend_class_entry * fe_ce = NULL ;
695
+
720
696
if (ZEND_TYPE_HAS_NAME (* single_type )) {
721
- zend_string * fe_class_name =
722
- resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
723
- zend_perform_covariant_class_type_check (
724
- fe_scope , fe_class_name , NULL ,
725
- proto_scope , proto_type , /* register_unresolved */ 1 );
697
+ fe_class_name = resolve_class_name (fe_scope , ZEND_TYPE_NAME (* single_type ));
726
698
} else if (ZEND_TYPE_HAS_CE (* single_type )) {
727
- zend_class_entry * fe_ce = ZEND_TYPE_CE (* single_type );
728
- zend_perform_covariant_class_type_check (
729
- fe_scope , fe_ce -> name , fe_ce ,
730
- proto_scope , proto_type , /* register_unresolved */ 1 );
699
+ fe_ce = ZEND_TYPE_CE (* single_type );
700
+ fe_class_name = fe_ce -> name ;
701
+ } else {
702
+ continue ;
703
+ }
704
+
705
+ if (UNEXPECTED (ZEND_TYPE_IS_INTERSECTION (proto_type ))) {
706
+ zend_is_single_type_subtype_intersection (fe_scope ,
707
+ fe_class_name , fe_ce , proto_scope , proto_type ,
708
+ /* register_unresolved */ true);
709
+ } else {
710
+ zend_perform_covariant_class_type_check (fe_scope ,
711
+ fe_class_name , fe_ce , proto_scope , proto_type ,
712
+ /* register_unresolved */ true);
731
713
}
732
714
} ZEND_TYPE_FOREACH_END ();
733
715
}
0 commit comments