summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug69957.phpt12
-rw-r--r--Zend/tests/compound_assign_with_numeric_strings.phpt8
-rw-r--r--Zend/tests/mod_001.phpt6
-rw-r--r--Zend/zend_exceptions.c5
-rw-r--r--Zend/zend_exceptions.h1
-rw-r--r--Zend/zend_operators.c2
-rw-r--r--Zend/zend_vm_def.h2
-rw-r--r--Zend/zend_vm_execute.h18
8 files changed, 30 insertions, 24 deletions
diff --git a/Zend/tests/bug69957.phpt b/Zend/tests/bug69957.phpt
index 7f2c76b918..5aa0edab21 100644
--- a/Zend/tests/bug69957.phpt
+++ b/Zend/tests/bug69957.phpt
@@ -64,16 +64,16 @@ try {
float(INF)
Variable mod
-Type: Exception
-Message: Division by zero
+Type: DivisionByZeroError
+Message: Modulo by zero
float(INF)
Literal mod
-Type: Exception
-Message: Division by zero
+Type: DivisionByZeroError
+Message: Modulo by zero
float(INF)
Double mod
-Type: Exception
-Message: Division by zero
+Type: DivisionByZeroError
+Message: Modulo by zero
diff --git a/Zend/tests/compound_assign_with_numeric_strings.phpt b/Zend/tests/compound_assign_with_numeric_strings.phpt
index 518ed9ee7e..fbfc1605ec 100644
--- a/Zend/tests/compound_assign_with_numeric_strings.phpt
+++ b/Zend/tests/compound_assign_with_numeric_strings.phpt
@@ -11,7 +11,7 @@ $n = "-1";
try {
$n <<= $n;
var_dump($n);
-} catch (Exception $e) {
+} catch (Throwable $e) {
echo "\nException: " . $e->getMessage() . "\n";
}
@@ -23,7 +23,7 @@ $n = "-1";
try {
$n >>= $n;
var_dump($n);
-} catch (Exception $e) {
+} catch (Throwable $e) {
echo "\nException: " . $e->getMessage() . "\n";
}
@@ -31,7 +31,7 @@ $n = "0";
try{
$n %= $n;
var_dump($n);
-} catch (Exception $e) {
+} catch (Throwable $e) {
echo "\nException: " . $e->getMessage() . "\n";
}
@@ -46,5 +46,5 @@ int(0)
Exception: Bit shift by negative number
-Exception: Division by zero
+Exception: Modulo by zero
int(0)
diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt
index 8dda405abf..ff589e2fee 100644
--- a/Zend/tests/mod_001.phpt
+++ b/Zend/tests/mod_001.phpt
@@ -9,12 +9,12 @@ $b = array();
try {
$c = $a % $b;
var_dump($c);
-} catch (Exception $e) {
+} catch (Throwable $e) {
echo "Exception: " . $e->getMessage() . "\n";
}
echo "Done\n";
?>
---EXPECTF--
-Exception: Division by zero
+--EXPECT--
+Exception: Modulo by zero
Done
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index b0547b07a9..9f5b2448d1 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -31,6 +31,7 @@
#include "zend_smart_str.h"
ZEND_API zend_class_entry *zend_ce_throwable;
+ZEND_API zend_class_entry *zend_ce_division_by_zero_error;
static zend_class_entry *default_exception_ce;
static zend_class_entry *error_exception_ce;
@@ -853,6 +854,10 @@ void zend_register_default_exception(void) /* {{{ */
INIT_CLASS_ENTRY(ce, "TypeError", NULL);
type_error_ce = zend_register_internal_class_ex(&ce, error_ce);
type_error_ce->create_object = zend_default_exception_new;
+
+ INIT_CLASS_ENTRY(ce, "DivisionByZeroError", NULL);
+ zend_ce_division_by_zero_error = zend_register_internal_class_ex(&ce, error_ce);
+ zend_ce_division_by_zero_error->create_object = zend_default_exception_new;
}
/* }}} */
diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h
index 944fe555ce..f07bc78b88 100644
--- a/Zend/zend_exceptions.h
+++ b/Zend/zend_exceptions.h
@@ -27,6 +27,7 @@
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_throwable;
+extern ZEND_API zend_class_entry *zend_ce_division_by_zero_error;
ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous);
ZEND_API void zend_exception_save(void);
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 7abd978079..a669cc206c 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -1157,7 +1157,7 @@ ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {
if (op2_lval == 0) {
/* modulus by zero */
if (EG(current_execute_data) && !CG(in_compilation)) {
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
} else {
zend_error_noreturn(E_ERROR, "Division by zero");
}
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 66398e5bfa..294a9ba9c7 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -189,7 +189,7 @@ ZEND_VM_HANDLER(5, ZEND_MOD, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 994a15859c..729ad1be6d 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -4493,7 +4493,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CONST_CONST_HANDLER(Z
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -8516,7 +8516,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CONST_CV_HANDLER(ZEND
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -10391,7 +10391,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CONST_TMPVAR_HANDLER(
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -30189,7 +30189,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CV_CONST_HANDLER(ZEND
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -35497,7 +35497,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CV_CV_HANDLER(ZEND_OP
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -38228,7 +38228,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_CV_TMPVAR_HANDLER(ZEN
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -41301,7 +41301,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_TMPVAR_CONST_HANDLER(
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -43731,7 +43731,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_TMPVAR_CV_HANDLER(ZEN
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
@@ -44894,7 +44894,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_MOD_SPEC_TMPVAR_TMPVAR_HANDLER
result = EX_VAR(opline->result.var);
if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
SAVE_OPLINE();
- zend_throw_exception_ex(NULL, 0, "Division by zero");
+ zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
HANDLE_EXCEPTION();
} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */