@@ -453,8 +453,9 @@ static inheritance_status zend_is_intersection_subtype_of_class(
453453
454454/* Check whether a single class proto type is a subtype of a potentially complex fe_type. */
455455static 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 ,
457457 zend_class_entry * proto_scope , zend_type proto_type ) {
458+ zend_class_entry * fe_ce = NULL ;
458459 bool have_unresolved = 0 ;
459460
460461 /* 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(
529530 return is_intersection ? INHERITANCE_SUCCESS : INHERITANCE_ERROR ;
530531}
531532
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 ) {
534534 if (ZEND_TYPE_HAS_NAME (single_type )) {
535- * ce = NULL ;
536535 return resolve_class_name (scope , ZEND_TYPE_NAME (single_type ));
537536 }
538537 return NULL ;
@@ -607,14 +606,11 @@ static inheritance_status zend_perform_covariant_type_check(
607606 if (proto_type_mask & (MAY_BE_OBJECT |MAY_BE_ITERABLE )) {
608607 bool any_class = (proto_type_mask & MAY_BE_OBJECT ) != 0 ;
609608 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 );
612610 if (!fe_class_name ) {
613611 continue ;
614612 }
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 );
618614 if (fe_ce ) {
619615 if (any_class || unlinked_instanceof (fe_ce , zend_ce_traversable )) {
620616 track_class_dependency (fe_ce , fe_class_name );
@@ -633,13 +629,12 @@ static inheritance_status zend_perform_covariant_type_check(
633629 early_exit_status =
634630 ZEND_TYPE_IS_INTERSECTION (proto_type ) ? INHERITANCE_ERROR : INHERITANCE_SUCCESS ;
635631 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 );
639633 if (!proto_class_name ) {
640634 continue ;
641635 }
642636
637+ zend_class_entry * proto_ce = NULL ;
643638 inheritance_status status = zend_is_intersection_subtype_of_class (
644639 fe_scope , fe_type , proto_scope , proto_class_name , proto_ce );
645640 if (status == early_exit_status ) {
@@ -656,14 +651,13 @@ static inheritance_status zend_perform_covariant_type_check(
656651 * whether proto_type is a union or intersection (only the inner check differs). */
657652 early_exit_status = INHERITANCE_ERROR ;
658653 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 );
661655 if (!fe_class_name ) {
662656 continue ;
663657 }
664658
665659 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 );
667661 if (status == early_exit_status ) {
668662 return status ;
669663 }
0 commit comments