@@ -453,8 +453,9 @@ static inheritance_status zend_is_intersection_subtype_of_class(
453
453
454
454
/* Check whether a single class proto type is a subtype of a potentially complex fe_type. */
455
455
static inheritance_status zend_is_class_subtype_of_type (
456
- zend_class_entry * fe_scope , zend_string * fe_class_name , zend_class_entry * fe_ce ,
456
+ zend_class_entry * fe_scope , zend_string * fe_class_name ,
457
457
zend_class_entry * proto_scope , zend_type proto_type ) {
458
+ zend_class_entry * fe_ce = NULL ;
458
459
bool have_unresolved = 0 ;
459
460
460
461
/* If the parent has 'object' as a return type, any class satisfies the co-variant check */
@@ -529,10 +530,8 @@ static inheritance_status zend_is_class_subtype_of_type(
529
530
return is_intersection ? INHERITANCE_SUCCESS : INHERITANCE_ERROR ;
530
531
}
531
532
532
- static zend_string * get_class_from_type (
533
- zend_class_entry * * ce , zend_class_entry * scope , zend_type single_type ) {
533
+ static zend_string * get_class_from_type (zend_class_entry * scope , zend_type single_type ) {
534
534
if (ZEND_TYPE_HAS_NAME (single_type )) {
535
- * ce = NULL ;
536
535
return resolve_class_name (scope , ZEND_TYPE_NAME (single_type ));
537
536
}
538
537
return NULL ;
@@ -607,14 +606,11 @@ static inheritance_status zend_perform_covariant_type_check(
607
606
if (proto_type_mask & (MAY_BE_OBJECT |MAY_BE_ITERABLE )) {
608
607
bool any_class = (proto_type_mask & MAY_BE_OBJECT ) != 0 ;
609
608
ZEND_TYPE_FOREACH (fe_type , single_type ) {
610
- zend_class_entry * fe_ce ;
611
- zend_string * fe_class_name = get_class_from_type (& fe_ce , fe_scope , * single_type );
609
+ zend_string * fe_class_name = get_class_from_type (fe_scope , * single_type );
612
610
if (!fe_class_name ) {
613
611
continue ;
614
612
}
615
- if (!fe_ce ) {
616
- fe_ce = lookup_class (fe_scope , fe_class_name );
617
- }
613
+ zend_class_entry * fe_ce = lookup_class (fe_scope , fe_class_name );
618
614
if (fe_ce ) {
619
615
if (any_class || unlinked_instanceof (fe_ce , zend_ce_traversable )) {
620
616
track_class_dependency (fe_ce , fe_class_name );
@@ -633,13 +629,12 @@ static inheritance_status zend_perform_covariant_type_check(
633
629
early_exit_status =
634
630
ZEND_TYPE_IS_INTERSECTION (proto_type ) ? INHERITANCE_ERROR : INHERITANCE_SUCCESS ;
635
631
ZEND_TYPE_FOREACH (proto_type , single_type ) {
636
- zend_class_entry * proto_ce ;
637
- zend_string * proto_class_name =
638
- get_class_from_type (& proto_ce , proto_scope , * single_type );
632
+ zend_string * proto_class_name = get_class_from_type (proto_scope , * single_type );
639
633
if (!proto_class_name ) {
640
634
continue ;
641
635
}
642
636
637
+ zend_class_entry * proto_ce = NULL ;
643
638
inheritance_status status = zend_is_intersection_subtype_of_class (
644
639
fe_scope , fe_type , proto_scope , proto_class_name , proto_ce );
645
640
if (status == early_exit_status ) {
@@ -656,14 +651,13 @@ static inheritance_status zend_perform_covariant_type_check(
656
651
* whether proto_type is a union or intersection (only the inner check differs). */
657
652
early_exit_status = INHERITANCE_ERROR ;
658
653
ZEND_TYPE_FOREACH (fe_type , single_type ) {
659
- zend_class_entry * fe_ce ;
660
- zend_string * fe_class_name = get_class_from_type (& fe_ce , fe_scope , * single_type );
654
+ zend_string * fe_class_name = get_class_from_type (fe_scope , * single_type );
661
655
if (!fe_class_name ) {
662
656
continue ;
663
657
}
664
658
665
659
inheritance_status status = zend_is_class_subtype_of_type (
666
- fe_scope , fe_class_name , fe_ce , proto_scope , proto_type );
660
+ fe_scope , fe_class_name , proto_scope , proto_type );
667
661
if (status == early_exit_status ) {
668
662
return status ;
669
663
}
0 commit comments