diff --git a/Zend/tests/in-de-crement/overloaded_access.phpt b/Zend/tests/in-de-crement/overloaded_access.phpt new file mode 100644 index 0000000000000..56a5c2b1d47a0 --- /dev/null +++ b/Zend/tests/in-de-crement/overloaded_access.phpt @@ -0,0 +1,36 @@ +--TEST-- +Overloaded array access with pre increment/decrement +--FILE-- +getMessage() . "\n"; +} +$foo = new Foo; +try { + $foo[0]--; +} catch (Throwable $ex) { + echo $ex->getMessage() . "\n"; +} +?> +--EXPECT-- +Cannot increment array +Cannot decrement array diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 1a95059020018..416725788836f 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1500,15 +1500,9 @@ ZEND_VM_HELPER(zend_pre_inc_helper, VAR|CV, ANY) } } increment_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } @@ -1559,15 +1553,9 @@ ZEND_VM_HELPER(zend_pre_dec_helper, VAR|CV, ANY) } } decrement_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 881dec2d9d3fd..893f727c26837 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -21624,15 +21624,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_inc_help } } increment_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } @@ -21701,15 +21695,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_dec_help } } decrement_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } @@ -39007,15 +38995,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_inc_help } } increment_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); } @@ -39083,15 +39065,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_pre_dec_help } } decrement_function(var_ptr); - if (UNEXPECTED(EG(exception))) { - /* Smart branch expects result to be set with exceptions */ - if (UNEXPECTED(RETURN_VALUE_USED(opline))) { - ZVAL_NULL(EX_VAR(opline->result.var)); - } - HANDLE_EXCEPTION(); - } } while (0); + /* opcodes are expected to set the result value */ if (UNEXPECTED(RETURN_VALUE_USED(opline))) { ZVAL_COPY(EX_VAR(opline->result.var), var_ptr); }