@@ -4098,15 +4098,15 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
4098
4098
{
4099
4099
USE_OPLINE
4100
4100
4101
- SAVE_OPLINE ();
4102
4101
if (OP1_TYPE == IS_UNUSED ) {
4102
+ SAVE_OPLINE ();
4103
4103
zend_verify_missing_return_type (EX (func ), CACHE_ADDR (opline -> op2 .num ));
4104
+ HANDLE_EXCEPTION ();
4104
4105
} else {
4105
4106
/* prevents "undefined variable opline" errors */
4106
4107
#if !ZEND_VM_SPEC || (OP1_TYPE != IS_UNUSED )
4107
4108
zval * retval_ref , * retval_ptr ;
4108
4109
zend_arg_info * ret_info = EX (func )-> common .arg_info - 1 ;
4109
-
4110
4110
retval_ref = retval_ptr = GET_OP1_ZVAL_PTR (BP_VAR_R );
4111
4111
4112
4112
if (OP1_TYPE == IS_CONST ) {
@@ -4121,24 +4121,35 @@ ZEND_VM_COLD_CONST_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV
4121
4121
ZVAL_DEREF (retval_ptr );
4122
4122
}
4123
4123
4124
- if (UNEXPECTED ((ZEND_TYPE_FULL_MASK (ret_info -> type ) & MAY_BE_ANY )
4125
- && !ZEND_TYPE_CONTAINS_CODE (ret_info -> type , Z_TYPE_P (retval_ptr ))
4126
- && !(EX (func )-> op_array .fn_flags & ZEND_ACC_RETURN_REFERENCE )
4127
- && retval_ref != retval_ptr )
4128
- ) {
4129
- /* A cast might happen - unwrap the reference if this is a by-value return */
4130
- if (Z_REFCOUNT_P (retval_ref ) == 1 ) {
4131
- ZVAL_UNREF (retval_ref );
4124
+ if (EXPECTED (ZEND_TYPE_CONTAINS_CODE (ret_info -> type , Z_TYPE_P (retval_ptr )))) {
4125
+ ZEND_VM_NEXT_OPCODE ();
4126
+ }
4127
+
4128
+ zend_reference * ref = NULL ;
4129
+ void * cache_slot = CACHE_ADDR (opline -> op2 .num );
4130
+ if (UNEXPECTED (retval_ref != retval_ptr )) {
4131
+ if (UNEXPECTED (EX (func )-> op_array .fn_flags & ZEND_ACC_RETURN_REFERENCE )) {
4132
+ ref = Z_REF_P (retval_ref );
4132
4133
} else {
4133
- Z_DELREF_P (retval_ref );
4134
- ZVAL_COPY (retval_ref , retval_ptr );
4134
+ /* A cast might happen - unwrap the reference if this is a by-value return */
4135
+ if (Z_REFCOUNT_P (retval_ref ) == 1 ) {
4136
+ ZVAL_UNREF (retval_ref );
4137
+ } else {
4138
+ Z_DELREF_P (retval_ref );
4139
+ ZVAL_COPY (retval_ref , retval_ptr );
4140
+ }
4141
+ retval_ptr = retval_ref ;
4135
4142
}
4136
- retval_ptr = retval_ref ;
4137
4143
}
4138
- zend_verify_return_type (EX (func ), retval_ptr , CACHE_ADDR (opline -> op2 .num ));
4144
+
4145
+ SAVE_OPLINE ();
4146
+ if (UNEXPECTED (!zend_check_type_slow (ret_info -> type , retval_ptr , ref , cache_slot , NULL , 1 , 0 ))) {
4147
+ zend_verify_return_error (EX (func ), cache_slot , retval_ptr );
4148
+ HANDLE_EXCEPTION ();
4149
+ }
4150
+ ZEND_VM_NEXT_OPCODE ();
4139
4151
#endif
4140
4152
}
4141
- ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION ();
4142
4153
}
4143
4154
4144
4155
ZEND_VM_INLINE_HANDLER (62 , ZEND_RETURN , CONST |TMP |VAR |CV , ANY )
0 commit comments