@@ -2642,58 +2642,6 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr, uint32_t t
26422642}
26432643/* }}} */
26442644
2645- static bool zend_is_this_instance_of_name (const zend_string * type_name )
2646- {
2647- if (zend_string_equals_ci (CG (active_class_entry )-> name , type_name )) {
2648- return true;
2649- }
2650- if (zend_string_equals_ci (type_name , ZSTR_KNOWN (ZEND_STR_SELF ))) {
2651- return true;
2652- }
2653- if (zend_string_equals_ci (type_name , ZSTR_KNOWN (ZEND_STR_PARENT ))) {
2654- return true;
2655- }
2656-
2657- ZEND_ASSERT ((CG (active_class_entry )-> ce_flags & ZEND_ACC_LINKED ) == 0 );
2658- if (CG (active_class_entry )-> num_interfaces ) {
2659- for (uint32_t i = 0 ; i < CG (active_class_entry )-> num_interfaces ; i ++ ) {
2660- if (zend_string_equals_ci (CG (active_class_entry )-> interface_names [i ].lc_name , type_name )) {
2661- return true;
2662- }
2663- }
2664- }
2665- const zend_string * parent_name = CG (active_class_entry )-> parent_name ;
2666- if (parent_name && zend_string_equals_ci (parent_name , type_name )) {
2667- return true;
2668- }
2669-
2670- return false;
2671- }
2672-
2673- static bool zend_is_this_valid_for_return_type (zend_type type )
2674- {
2675- /* Closures can be bound to a class scope, however it might not and this must type error */
2676- if (CG (active_op_array )-> fn_flags & ZEND_ACC_CLOSURE ) {
2677- return false;
2678- }
2679-
2680- if (ZEND_TYPE_FULL_MASK (type ) & (MAY_BE_OBJECT |MAY_BE_STATIC )) {
2681- return true;
2682- }
2683-
2684- const zend_type * single_type ;
2685- ZEND_TYPE_FOREACH (type , single_type ) {
2686- if (ZEND_TYPE_HAS_NAME (* single_type )) {
2687- const zend_string * name = ZEND_TYPE_NAME (* single_type );
2688- if (zend_is_this_instance_of_name (name )) {
2689- return true;
2690- }
2691- }
2692- } ZEND_TYPE_FOREACH_END ();
2693-
2694- return false;
2695- }
2696-
26972645static void zend_emit_return_type_check (
26982646 znode * expr , const zend_arg_info * return_info , bool implicit ) /* {{{ */
26992647{
@@ -2749,17 +2697,6 @@ static void zend_emit_return_type_check(
27492697 return ;
27502698 }
27512699
2752- /* If return type contains static and we are returning $this
2753- * (determined by checking if the previous opcode is ZEND_FETCH_THIS)
2754- * then we don't need to check the return type */
2755- const zend_op_array * op_array = CG (active_op_array );
2756- if (expr && op_array -> last >= 1
2757- && op_array -> opcodes [op_array -> last - 1 ].opcode == ZEND_FETCH_THIS
2758- && zend_is_this_valid_for_return_type (type )) {
2759- ZEND_ASSERT ((expr -> op_type & (IS_VAR |IS_TMP_VAR )) && expr -> u .op .var == op_array -> opcodes [op_array -> last - 1 ].result .var );
2760- return ;
2761- }
2762-
27632700 opline = zend_emit_op (NULL , ZEND_VERIFY_RETURN_TYPE , expr , NULL );
27642701 if (expr && expr -> op_type == IS_CONST ) {
27652702 opline -> result_type = expr -> op_type = IS_TMP_VAR ;
0 commit comments