Commit b74e0f749d2 for php.net

commit b74e0f749d23d170e714f4b33f0ac882635a53f9
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date:   Sun Aug 2 05:06:14 2026 +0700

    ext/gmp: applied fixers to improve test robustness (#22987)

diff --git a/ext/gmp/tests/003.phpt b/ext/gmp/tests/003.phpt
index 8fdd723e8c4..df9fd229fd8 100644
--- a/ext/gmp/tests/003.phpt
+++ b/ext/gmp/tests/003.phpt
@@ -26,7 +26,7 @@
         try {
             $test[] = gmp_init("4d2");
         } catch (\ValueError $e) {
-            echo $e->getMessage() . \PHP_EOL;
+            echo $e::class, ': ', $e->getMessage(), PHP_EOL;
         }
         $test[] = gmp_init("4d2", 16);

@@ -35,7 +35,7 @@
         }
 ?>
 --EXPECT--
-gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
 1234
 1234
 10011010010
diff --git a/ext/gmp/tests/bug32773.phpt b/ext/gmp/tests/bug32773.phpt
index 3df59e67faf..0f2b862897c 100644
--- a/ext/gmp/tests/bug32773.phpt
+++ b/ext/gmp/tests/bug32773.phpt
@@ -10,17 +10,17 @@
 try {
     var_dump(gmp_div(10, 0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_div_qr(10, 0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
 --EXPECT--
 10 + 0 = 10
 10 + "0" = 10
-gmp_div(): Argument #2 ($num2) Division by zero
-gmp_div_qr(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div_qr(): Argument #2 ($num2) Division by zero
diff --git a/ext/gmp/tests/bug50283.phpt b/ext/gmp/tests/bug50283.phpt
index db0e456da0e..5f1806e508f 100644
--- a/ext/gmp/tests/bug50283.phpt
+++ b/ext/gmp/tests/bug50283.phpt
@@ -10,34 +10,34 @@
 try {
     printf("Decimal: %s, -1-based: %s\n", gmp_strval($a), gmp_strval($a,-1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     printf("Decimal: %s, 1-based: %s\n", gmp_strval($a), gmp_strval($a,1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     printf("Decimal: %s, -37-based: %s\n", gmp_strval($a), gmp_strval($a,-37));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 printf("Decimal: %s, 37-based: %s\n", gmp_strval($a), gmp_strval($a,37));
 printf("Decimal: %s, 62-based: %s\n", gmp_strval($a), gmp_strval($a,62));
 try {
     printf("Decimal: %s, 63-based: %s\n\n", gmp_strval($a), gmp_strval($a,63));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62));
 ?>
 --EXPECT--
 Decimal: 71915494046709, -36-based: PHPISCOOL
 Decimal: 71915494046709, 36-based: phpiscool
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
 Decimal: 71915494046709, 37-based: KHKATELJF
 Decimal: 71915494046709, 62-based: KQ6yq741
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
 Base 32 and 62-based: 1NHkAcdIiD
diff --git a/ext/gmp/tests/bug66872.phpt b/ext/gmp/tests/bug66872.phpt
index 3d65a910b78..67870c06752 100644
--- a/ext/gmp/tests/bug66872.phpt
+++ b/ext/gmp/tests/bug66872.phpt
@@ -8,9 +8,9 @@
 try {
     var_dump(gmp_testbit("abc", 1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
 --EXPECT--
-gmp_testbit(): Argument #1 ($num) is not an integer string
+ValueError: gmp_testbit(): Argument #1 ($num) is not an integer string
diff --git a/ext/gmp/tests/bug80560.phpt b/ext/gmp/tests/bug80560.phpt
index 85f4dff96be..2788c51e35d 100644
--- a/ext/gmp/tests/bug80560.phpt
+++ b/ext/gmp/tests/bug80560.phpt
@@ -72,24 +72,24 @@
 try {
     var_dump(gmp_init('0X', 16));
 } catch (\ValueError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_init('0x', 16));
 } catch (\ValueError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo 'Binary', \PHP_EOL;
 try {
     var_dump(gmp_init('0B', 2));
 } catch (\ValueError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_init('0b', 2));
 } catch (\ValueError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo 'Fuzzing gmp functions:', \PHP_EOL;
@@ -219,10 +219,10 @@
 --EXPECT--
 Explicit base with gmp_init:
 Hexadecimal
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
 Binary
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
 Fuzzing gmp functions:
 Done
diff --git a/ext/gmp/tests/bug81119.phpt b/ext/gmp/tests/bug81119.phpt
index e689a7251f6..8747871b11a 100644
--- a/ext/gmp/tests/bug81119.phpt
+++ b/ext/gmp/tests/bug81119.phpt
@@ -10,7 +10,7 @@ function test($f) {
         $f();
         echo "No error?\n";
     } catch (TypeError|ValueError $e) {
-        echo $e->getMessage(), "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
 }
 test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < "x");
@@ -20,7 +20,7 @@ function test($f) {

 ?>
 --EXPECT--
-Number is not an integer string
-Number must be of type GMP|string|int, array given
-Number is not an integer string
-Number must be of type GMP|string|int, array given
+ValueError: Number is not an integer string
+TypeError: Number must be of type GMP|string|int, array given
+ValueError: Number is not an integer string
+TypeError: Number must be of type GMP|string|int, array given
diff --git a/ext/gmp/tests/comparison_invalid.phpt b/ext/gmp/tests/comparison_invalid.phpt
index edf24e889b8..46ea036eae2 100644
--- a/ext/gmp/tests/comparison_invalid.phpt
+++ b/ext/gmp/tests/comparison_invalid.phpt
@@ -8,13 +8,13 @@
 try {
     var_dump("hapfegfbu" > gmp_init(0));
 } catch (\Error $e) {
-    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump((new DateTime()) > gmp_init(0));
 } catch (\Error $e) {
-    echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
diff --git a/ext/gmp/tests/construct.phpt b/ext/gmp/tests/construct.phpt
index 1b23bd791ed..28957bc5eee 100644
--- a/ext/gmp/tests/construct.phpt
+++ b/ext/gmp/tests/construct.phpt
@@ -12,17 +12,17 @@
 try {
     var_dump(new GMP("12", 999));
 } catch (ValueError $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump(new GMP("", 10));
 } catch (ValueError $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump(new GMP("hello"));
 } catch (ValueError $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
@@ -46,6 +46,6 @@
   ["num"]=>
   string(1) "6"
 }
-GMP::__construct(): Argument #2 ($base) must be 0 or between 2 and 62
-GMP::__construct(): Argument #1 ($num) is not an integer string
-GMP::__construct(): Argument #1 ($num) is not an integer string
+ValueError: GMP::__construct(): Argument #2 ($base) must be 0 or between 2 and 62
+ValueError: GMP::__construct(): Argument #1 ($num) is not an integer string
+ValueError: GMP::__construct(): Argument #1 ($num) is not an integer string
diff --git a/ext/gmp/tests/gh16501.phpt b/ext/gmp/tests/gh16501.phpt
index 325be85d191..351370ff1b7 100644
--- a/ext/gmp/tests/gh16501.phpt
+++ b/ext/gmp/tests/gh16501.phpt
@@ -7,8 +7,8 @@
 try {
 	gmp_random_bits(PHP_INT_MAX);
 } catch (\ValueError $e) {
-	echo $e->getMessage();
+	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECTF--
-gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
+ValueError: gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
diff --git a/ext/gmp/tests/gh9308.phpt b/ext/gmp/tests/gh9308.phpt
index af13b8bdf32..94295c8226c 100644
--- a/ext/gmp/tests/gh9308.phpt
+++ b/ext/gmp/tests/gh9308.phpt
@@ -11,9 +11,9 @@
 try {
     $gmp = gmp_init(gmp_init(123));
 } catch (\TypeError $e) {
-    echo $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
 --EXPECT--
-gmp_init(): Argument #1 ($num) must be of type string|int, GMP given
+TypeError: gmp_init(): Argument #1 ($num) must be of type string|int, GMP given
diff --git a/ext/gmp/tests/gmp_abs.phpt b/ext/gmp/tests/gmp_abs.phpt
index 23fac5be5de..0d75efc7ff5 100644
--- a/ext/gmp/tests/gmp_abs.phpt
+++ b/ext/gmp/tests/gmp_abs.phpt
@@ -8,14 +8,14 @@
 try {
     var_dump(gmp_strval(gmp_abs("")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval(gmp_abs("0")));
 var_dump(gmp_strval(gmp_abs(0)));
 try {
     var_dump(gmp_strval(gmp_abs(-111111111111111111111))); // This is a float
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval(gmp_abs("111111111111111111111")));
 var_dump(gmp_strval(gmp_abs("-111111111111111111111")));
@@ -25,33 +25,33 @@
     // Base 8
     var_dump(gmp_strval(gmp_abs("09876543")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     // Base 8
     var_dump(gmp_strval(gmp_abs("-099987654")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }


 try {
     var_dump(gmp_abs(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECT--
-gmp_abs(): Argument #1 ($num) is not an integer string
+ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
 string(1) "0"
 string(1) "0"
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
 string(21) "111111111111111111111"
 string(21) "111111111111111111111"
 string(1) "0"
-gmp_abs(): Argument #1 ($num) is not an integer string
-gmp_abs(): Argument #1 ($num) is not an integer string
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
+ValueError: gmp_abs(): Argument #1 ($num) is not an integer string
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_and.phpt b/ext/gmp/tests/gmp_and.phpt
index f2356dc835a..c5eff64fa26 100644
--- a/ext/gmp/tests/gmp_and.phpt
+++ b/ext/gmp/tests/gmp_and.phpt
@@ -14,7 +14,7 @@
 try {
     var_dump(gmp_strval(gmp_and("test", "no test")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $n = gmp_init("987657876543456");
@@ -26,17 +26,17 @@
 try {
     var_dump(gmp_and(array(), 1));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_and(1, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_and(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -47,10 +47,10 @@
 string(3) "515"
 string(4) "3333"
 string(4) "4544"
-gmp_and(): Argument #1 ($num1) is not an integer string
+ValueError: gmp_and(): Argument #1 ($num1) is not an integer string
 string(4) "1536"
 string(15) "424703623692768"
-gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_and(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_and(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_and(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_binomial.phpt b/ext/gmp/tests/gmp_binomial.phpt
index 1bf371e68a1..7cca4c7f578 100644
--- a/ext/gmp/tests/gmp_binomial.phpt
+++ b/ext/gmp/tests/gmp_binomial.phpt
@@ -23,7 +23,7 @@
 try {
     var_dump(gmp_binomial(5, -2));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECTF--
@@ -67,4 +67,4 @@
   ["num"]=>
   string(1) "7"
 }
-gmp_binomial(): Argument #2 ($k) must be between 0 and %d
+ValueError: gmp_binomial(): Argument #2 ($k) must be between 0 and %d
diff --git a/ext/gmp/tests/gmp_clrbit.phpt b/ext/gmp/tests/gmp_clrbit.phpt
index afefa740f10..9dc63a87f5a 100644
--- a/ext/gmp/tests/gmp_clrbit.phpt
+++ b/ext/gmp/tests/gmp_clrbit.phpt
@@ -13,7 +13,7 @@
 try {
     gmp_clrbit($n, -1);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval($n));

@@ -21,7 +21,7 @@
 try {
     gmp_clrbit($n, -1);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval($n));

@@ -39,18 +39,18 @@
 try {
     gmp_clrbit($n, 3);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 echo "Done\n";
 ?>
 --EXPECTF--
 string(1) "0"
-gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
 string(2) "-1"
-gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_clrbit(): Argument #2 ($index) must be between 0 and %d * %d
 string(7) "1000000"
 string(7) "1000000"
 string(30) "238462734628347239571822592658"
-gmp_clrbit(): Argument #1 ($num) must be of type GMP, array given
+TypeError: gmp_clrbit(): Argument #1 ($num) must be of type GMP, array given
 Done
diff --git a/ext/gmp/tests/gmp_cmp.phpt b/ext/gmp/tests/gmp_cmp.phpt
index 535d23cc4a2..8e5b68e801f 100644
--- a/ext/gmp/tests/gmp_cmp.phpt
+++ b/ext/gmp/tests/gmp_cmp.phpt
@@ -30,7 +30,7 @@ function cmp_helper($l, $r) {
 try {
     var_dump(gmp_cmp(array(),array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -44,5 +44,5 @@ function cmp_helper($l, $r) {
 gmp(0, 345355): right greater than left
 bool(true)
 bool(true)
-gmp_cmp(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_cmp(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_com.phpt b/ext/gmp/tests/gmp_com.phpt
index 344903a13c3..5d92494c4bb 100644
--- a/ext/gmp/tests/gmp_com.phpt
+++ b/ext/gmp/tests/gmp_com.phpt
@@ -10,7 +10,7 @@
 try {
     var_dump(gmp_strval(gmp_com("test")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval(gmp_com("2394876545678")));
 var_dump(gmp_strval(gmp_com("-111")));
@@ -25,7 +25,7 @@
 try {
     var_dump(gmp_strval(gmp_com(array())));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -33,12 +33,12 @@
 --EXPECT--
 string(2) "-1"
 string(2) "-1"
-gmp_com(): Argument #1 ($num) is not an integer string
+ValueError: gmp_com(): Argument #1 ($num) is not an integer string
 string(14) "-2394876545679"
 string(3) "110"
 string(7) "-874654"
 string(4) "9875"
 string(9) "-98765468"
 string(12) "-98765463338"
-gmp_com(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_com(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_div_q.phpt b/ext/gmp/tests/gmp_div_q.phpt
index 8d892c3ff0a..d02db8db9eb 100644
--- a/ext/gmp/tests/gmp_div_q.phpt
+++ b/ext/gmp/tests/gmp_div_q.phpt
@@ -10,14 +10,14 @@
 try {
     var_dump(gmp_div_q(1, 0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_div_q(12653,23482734));
 try {
     var_dump(gmp_div_q(12653,23482734, 10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_div_q(1123123,123));
 var_dump(gmp_div_q(1123123,123, 1));
@@ -31,12 +31,12 @@
 try {
     var_dump(gmp_div_q($fp, $fp));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_div_q(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -46,12 +46,12 @@
   ["num"]=>
   string(1) "0"
 }
-gmp_div_q(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div_q(): Argument #2 ($num2) Division by zero
 object(GMP)#2 (1) {
   ["num"]=>
   string(1) "0"
 }
-gmp_div_q(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
+ValueError: gmp_div_q(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
 object(GMP)#1 (1) {
   ["num"]=>
   string(4) "9131"
@@ -76,6 +76,6 @@
   ["num"]=>
   string(4) "9131"
 }
-gmp_div_q(): Argument #1 ($num1) must be of type GMP|string|int, resource given
-gmp_div_q(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_div_q(): Argument #1 ($num1) must be of type GMP|string|int, resource given
+TypeError: gmp_div_q(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_div_qr.phpt b/ext/gmp/tests/gmp_div_qr.phpt
index f7649b0208c..00234b5e635 100644
--- a/ext/gmp/tests/gmp_div_qr.phpt
+++ b/ext/gmp/tests/gmp_div_qr.phpt
@@ -10,19 +10,19 @@
 try {
     var_dump(gmp_div_qr(1,0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_div_qr(gmp_init(1), gmp_init(0)));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_div_qr(12653,23482734));
 try {
     var_dump(gmp_div_qr(12653,23482734, 10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_div_qr(1123123,123));
 var_dump(gmp_div_qr(1123123,123, 1));
@@ -37,12 +37,12 @@
 try {
     var_dump(gmp_div_qr($fp, $fp));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_div_qr(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -60,8 +60,8 @@
     string(1) "0"
   }
 }
-gmp_div_qr(): Argument #2 ($num2) Division by zero
-gmp_div_qr(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div_qr(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div_qr(): Argument #2 ($num2) Division by zero
 array(2) {
   [0]=>
   object(GMP)#2 (1) {
@@ -74,7 +74,7 @@
     string(5) "12653"
   }
 }
-gmp_div_qr(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
+ValueError: gmp_div_qr(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
 array(2) {
   [0]=>
   object(GMP)#4 (1) {
@@ -159,6 +159,6 @@
     string(2) "10"
   }
 }
-gmp_div_qr(): Argument #1 ($num1) must be of type GMP|string|int, resource given
-gmp_div_qr(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_div_qr(): Argument #1 ($num1) must be of type GMP|string|int, resource given
+TypeError: gmp_div_qr(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_div_r.phpt b/ext/gmp/tests/gmp_div_r.phpt
index 501284ad47f..124e07e0503 100644
--- a/ext/gmp/tests/gmp_div_r.phpt
+++ b/ext/gmp/tests/gmp_div_r.phpt
@@ -10,14 +10,14 @@
 try {
     var_dump($r = gmp_div_r(1,0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump($r = gmp_div_r(12653,23482734));
 try {
     var_dump($r = gmp_div_r(12653,23482734, 10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump($r = gmp_div_r(1123123,123));
 var_dump($r = gmp_div_r(1123123,123, 1));
@@ -31,12 +31,12 @@
 try {
     var_dump(gmp_div_r($fp, $fp));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_div_r(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -46,12 +46,12 @@
   ["num"]=>
   string(1) "0"
 }
-gmp_div_r(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_div_r(): Argument #2 ($num2) Division by zero
 object(GMP)#3 (1) {
   ["num"]=>
   string(5) "12653"
 }
-gmp_div_r(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
+ValueError: gmp_div_r(): Argument #3 ($rounding_mode) must be one of GMP_ROUND_ZERO, GMP_ROUND_PLUSINF, or GMP_ROUND_MINUSINF
 object(GMP)#2 (1) {
   ["num"]=>
   string(2) "10"
@@ -76,6 +76,6 @@
   ["num"]=>
   string(2) "10"
 }
-gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, resource given
-gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, resource given
+TypeError: gmp_div_r(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_divexact.phpt b/ext/gmp/tests/gmp_divexact.phpt
index ecd7df4fef2..79cc481e513 100644
--- a/ext/gmp/tests/gmp_divexact.phpt
+++ b/ext/gmp/tests/gmp_divexact.phpt
@@ -18,7 +18,7 @@
     $r = gmp_divexact("233", "0");
     var_dump(gmp_strval($r));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $r = gmp_divexact("100", "10");
@@ -42,7 +42,7 @@
 ?>
 --EXPECT--
 string(1) "0"
-gmp_divexact(): Argument #2 ($num2) Division by zero
+DivisionByZeroError: gmp_divexact(): Argument #2 ($num2) Division by zero
 string(2) "10"
 string(3) "512"
 string(19) "5000000000000000000"
diff --git a/ext/gmp/tests/gmp_export.phpt b/ext/gmp/tests/gmp_export.phpt
index 085bafbbcc3..b8022fb1df0 100644
--- a/ext/gmp/tests/gmp_export.phpt
+++ b/ext/gmp/tests/gmp_export.phpt
@@ -57,30 +57,30 @@
 try {
     var_dump(gmp_export(123, -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_export(123, 0));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 // Invalid options
 try {
     var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECT--
 bool(true)
 string(2) "ff"
-gmp_export(): Argument #2 ($word_size) must be greater than or equal to 1
-gmp_export(): Argument #2 ($word_size) must be greater than or equal to 1
-gmp_export(): Argument #3 ($flags) cannot use multiple word order options
-gmp_export(): Argument #3 ($flags) cannot use multiple endian options
+ValueError: gmp_export(): Argument #2 ($word_size) must be greater than or equal to 1
+ValueError: gmp_export(): Argument #2 ($word_size) must be greater than or equal to 1
+ValueError: gmp_export(): Argument #3 ($flags) cannot use multiple word order options
+ValueError: gmp_export(): Argument #3 ($flags) cannot use multiple endian options
diff --git a/ext/gmp/tests/gmp_fact.phpt b/ext/gmp/tests/gmp_fact.phpt
index b28f572c697..7ebdd5df72e 100644
--- a/ext/gmp/tests/gmp_fact.phpt
+++ b/ext/gmp/tests/gmp_fact.phpt
@@ -9,18 +9,18 @@
 try {
     var_dump(gmp_strval(gmp_fact("")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval(gmp_fact("0")));
 try {
     var_dump(gmp_strval(gmp_fact("-1")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval(gmp_fact(-1)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_strval(gmp_fact(20)));
@@ -34,28 +34,28 @@
 try {
     var_dump(gmp_strval(gmp_fact($n)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_fact(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECTF--
 string(1) "1"
-gmp_fact(): Argument #1 ($num) is not an integer string
+ValueError: gmp_fact(): Argument #1 ($num) is not an integer string
 string(1) "1"
-gmp_fact(): Argument #1 ($num) must be between 0 and %d
-gmp_fact(): Argument #1 ($num) must be between 0 and %d
+ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and %d
+ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and %d
 string(19) "2432902008176640000"
 string(65) "30414093201713378043612608166064768844377641568960512000000000000"
 string(7) "3628800"
 string(1) "1"
 string(9) "479001600"
-gmp_fact(): Argument #1 ($num) must be between 0 and %d
-gmp_fact(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and %d
+TypeError: gmp_fact(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_fact_overflow.phpt b/ext/gmp/tests/gmp_fact_overflow.phpt
index 2d22005818c..dd7984edaea 100644
--- a/ext/gmp/tests/gmp_fact_overflow.phpt
+++ b/ext/gmp/tests/gmp_fact_overflow.phpt
@@ -8,18 +8,18 @@
 try {
     var_dump(gmp_fact(gmp_pow(2, 100)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_fact(gmp_init("18446744073709551616")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECTF--
-gmp_fact(): Argument #1 ($num) must be between 0 and %d
-gmp_fact(): Argument #1 ($num) must be between 0 and %d
+ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and %d
+ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and %d
 Done
diff --git a/ext/gmp/tests/gmp_gcdext.phpt b/ext/gmp/tests/gmp_gcdext.phpt
index 530e0cb24c9..cb6284a575e 100644
--- a/ext/gmp/tests/gmp_gcdext.phpt
+++ b/ext/gmp/tests/gmp_gcdext.phpt
@@ -31,12 +31,12 @@
 try {
     var_dump(gmp_gcdext($val[0], array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_gcdext(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -62,6 +62,6 @@
 string(1) "1"
 string(3) "195"
 string(3) "195"
-gmp_gcdext(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_gcdext(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_gcdext(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_gcdext(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_hamdist.phpt b/ext/gmp/tests/gmp_hamdist.phpt
index 26de0f5a46e..aca4433d8a6 100644
--- a/ext/gmp/tests/gmp_hamdist.phpt
+++ b/ext/gmp/tests/gmp_hamdist.phpt
@@ -19,17 +19,17 @@
 try {
     var_dump(gmp_hamdist($n, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_hamdist(array(), $n));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_hamdist(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -42,7 +42,7 @@
 int(43)
 int(0)
 int(26)
-gmp_hamdist(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_hamdist(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_import.phpt b/ext/gmp/tests/gmp_import.phpt
index 6292738b554..781388c8b1b 100644
--- a/ext/gmp/tests/gmp_import.phpt
+++ b/ext/gmp/tests/gmp_import.phpt
@@ -51,49 +51,49 @@
 try {
     var_dump(gmp_import('a', -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_import('a', 0));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 // Invalid data lengths
 try {
     var_dump(gmp_import('a', 2));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_import('aa', 3));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_import(str_repeat('a', 100), 64));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 // Invalid options
 try {
     var_dump(gmp_import('a', 1, GMP_MSW_FIRST | GMP_LSW_FIRST));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_import('a', 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECT--
 bool(true)
-gmp_import(): Argument #2 ($word_size) must be greater than or equal to 1
-gmp_import(): Argument #2 ($word_size) must be greater than or equal to 1
-gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
-gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
-gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
-gmp_import(): Argument #3 ($flags) cannot use multiple word order options
-gmp_import(): Argument #3 ($flags) cannot use multiple endian options
+ValueError: gmp_import(): Argument #2 ($word_size) must be greater than or equal to 1
+ValueError: gmp_import(): Argument #2 ($word_size) must be greater than or equal to 1
+ValueError: gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
+ValueError: gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
+ValueError: gmp_import(): Argument #1 ($data) must be a multiple of argument #2 ($word_size)
+ValueError: gmp_import(): Argument #3 ($flags) cannot use multiple word order options
+ValueError: gmp_import(): Argument #3 ($flags) cannot use multiple endian options
diff --git a/ext/gmp/tests/gmp_init.phpt b/ext/gmp/tests/gmp_init.phpt
index 4032b54ba47..a41e63ef54f 100644
--- a/ext/gmp/tests/gmp_init.phpt
+++ b/ext/gmp/tests/gmp_init.phpt
@@ -10,23 +10,23 @@
 try {
     var_dump(gmp_init(1,-1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_init("",36));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_init("foo",3));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval(gmp_init("993247326237679187178",3)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -37,8 +37,8 @@
   string(8) "98765678"
 }
 string(8) "98765678"
-gmp_init(): Argument #2 ($base) must be 0 or between 2 and 62
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #2 ($base) must be 0 or between 2 and 62
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
 Done
diff --git a/ext/gmp/tests/gmp_intval.phpt b/ext/gmp/tests/gmp_intval.phpt
index 15a1cdcc3d8..310f4a03fe5 100644
--- a/ext/gmp/tests/gmp_intval.phpt
+++ b/ext/gmp/tests/gmp_intval.phpt
@@ -16,22 +16,22 @@
 try {
     var_dump(gmp_intval(""));
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump(gmp_intval(new stdclass));
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump(gmp_intval(array()));
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     var_dump(gmp_intval("1.0001"));
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 echo "Done\n";
@@ -42,8 +42,8 @@
 int(-2349828)
 int(2342344)
 int(12345678)
-gmp_intval(): Argument #1 ($num) is not an integer string
-gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
-gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, array given
-gmp_intval(): Argument #1 ($num) is not an integer string
+ValueError: gmp_intval(): Argument #1 ($num) is not an integer string
+TypeError: gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
+TypeError: gmp_intval(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_intval(): Argument #1 ($num) is not an integer string
 Done
diff --git a/ext/gmp/tests/gmp_invert.phpt b/ext/gmp/tests/gmp_invert.phpt
index e2cd5c252ab..16dbd075e4d 100644
--- a/ext/gmp/tests/gmp_invert.phpt
+++ b/ext/gmp/tests/gmp_invert.phpt
@@ -11,14 +11,14 @@
 try {
     var_dump(gmp_strval(gmp_invert(444,0)));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     $zero = new GMP(0);
     var_dump(gmp_invert(5, $zero));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "No inverse modulo\n";
@@ -36,17 +36,17 @@
 try {
     var_dump(gmp_invert(array(), 1));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_invert(1, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_invert(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -54,8 +54,8 @@
 --EXPECT--
 string(7) "2293131"
 string(4) "5827"
-Division by zero
-Division by zero
+DivisionByZeroError: Division by zero
+DivisionByZeroError: Division by zero
 No inverse modulo
 bool(false)
 bool(false)
@@ -63,7 +63,7 @@
 bool(false)
 string(22) "3498273496234234523441"
 string(1) "1"
-gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_invert(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_invert(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_jacobi.phpt b/ext/gmp/tests/gmp_jacobi.phpt
index 59fab662fa8..d28847a4655 100644
--- a/ext/gmp/tests/gmp_jacobi.phpt
+++ b/ext/gmp/tests/gmp_jacobi.phpt
@@ -23,17 +23,17 @@
 try {
     var_dump(gmp_jacobi(3, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_jacobi(array(), 3));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_jacobi(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -56,7 +56,7 @@
 string(2) "-1"
 string(1) "0"
 string(2) "-1"
-gmp_jacobi(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_jacobi(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_legendre.phpt b/ext/gmp/tests/gmp_legendre.phpt
index 4955558281d..fa3b2e05ad5 100644
--- a/ext/gmp/tests/gmp_legendre.phpt
+++ b/ext/gmp/tests/gmp_legendre.phpt
@@ -23,17 +23,17 @@
 try {
     var_dump(gmp_legendre(3, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_legendre(array(), 3));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_legendre(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -56,7 +56,7 @@
 string(2) "-1"
 string(1) "0"
 string(2) "-1"
-gmp_legendre(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_legendre(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_mod.phpt b/ext/gmp/tests/gmp_mod.phpt
index af2e5936d5c..f66edaeb10e 100644
--- a/ext/gmp/tests/gmp_mod.phpt
+++ b/ext/gmp/tests/gmp_mod.phpt
@@ -8,7 +8,7 @@
 try {
     var_dump(gmp_mod("",""));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_mod(0,1));
 var_dump(gmp_mod(0,-1));
@@ -16,13 +16,13 @@
 try {
     var_dump(gmp_mod(-1,0));
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_mod(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $a = gmp_init("-100000000");
@@ -33,7 +33,7 @@
 echo "Done\n";
 ?>
 --EXPECT--
-gmp_mod(): Argument #1 ($num1) is not an integer string
+ValueError: gmp_mod(): Argument #1 ($num1) is not an integer string
 object(GMP)#2 (1) {
   ["num"]=>
   string(1) "0"
@@ -42,8 +42,8 @@
   ["num"]=>
   string(1) "0"
 }
-gmp_mod(): Argument #2 ($num2) Modulo by zero
-gmp_mod(): Argument #1 ($num1) must be of type GMP|string|int, array given
+DivisionByZeroError: gmp_mod(): Argument #2 ($num2) Modulo by zero
+TypeError: gmp_mod(): Argument #1 ($num1) must be of type GMP|string|int, array given
 object(GMP)#4 (1) {
   ["num"]=>
   string(5) "31161"
diff --git a/ext/gmp/tests/gmp_neg.phpt b/ext/gmp/tests/gmp_neg.phpt
index 6a7177a6ed3..1f48c3cc7cf 100644
--- a/ext/gmp/tests/gmp_neg.phpt
+++ b/ext/gmp/tests/gmp_neg.phpt
@@ -13,7 +13,7 @@
 try {
     var_dump(gmp_intval(gmp_neg("")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_intval(gmp_neg(0)));
@@ -26,7 +26,7 @@
 try {
     var_dump(gmp_neg(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -36,9 +36,9 @@
 int(-1)
 int(1)
 int(1)
-gmp_neg(): Argument #1 ($num) is not an integer string
+ValueError: gmp_neg(): Argument #1 ($num) is not an integer string
 int(0)
 int(0)
 string(21) "-12345678901234567890"
-gmp_neg(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_neg(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt
index b907d7a84e9..6a6fb565e7d 100644
--- a/ext/gmp/tests/gmp_nextprime.phpt
+++ b/ext/gmp/tests/gmp_nextprime.phpt
@@ -19,19 +19,19 @@
     $n = gmp_nextprime(array());
     var_dump(gmp_strval($n));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     $n = gmp_nextprime("");
     var_dump(gmp_strval($n));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     $n = gmp_nextprime(new stdclass());
     var_dump(gmp_strval($n));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -42,7 +42,7 @@
 string(1) "2"
 string(4) "1009"
 string(6) "100003"
-gmp_nextprime(): Argument #1 ($num) must be of type GMP|string|int, array given
-gmp_nextprime(): Argument #1 ($num) is not an integer string
-gmp_nextprime(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
+TypeError: gmp_nextprime(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_nextprime(): Argument #1 ($num) is not an integer string
+TypeError: gmp_nextprime(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
 Done
diff --git a/ext/gmp/tests/gmp_null_bytes.phpt b/ext/gmp/tests/gmp_null_bytes.phpt
index 1518d342dda..910d754fa8b 100644
--- a/ext/gmp/tests/gmp_null_bytes.phpt
+++ b/ext/gmp/tests/gmp_null_bytes.phpt
@@ -16,13 +16,13 @@
     try {
         $test();
     } catch (ValueError $e) {
-        echo $label, ": ", $e->getMessage(), PHP_EOL;
+        echo $label, ': ', $e::class, ': ', $e->getMessage(), PHP_EOL;
     }
 }

 ?>
 --EXPECT--
-gmp_init: gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init prefix: gmp_init(): Argument #1 ($num) is not an integer string
-gmp_add: gmp_add(): Argument #1 ($num1) is not an integer string
-constructor: GMP::__construct(): Argument #1 ($num) is not an integer string
+gmp_init: ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+gmp_init prefix: ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+gmp_add: ValueError: gmp_add(): Argument #1 ($num1) is not an integer string
+constructor: ValueError: GMP::__construct(): Argument #1 ($num) is not an integer string
diff --git a/ext/gmp/tests/gmp_operator_rhs_gmp_overflow.phpt b/ext/gmp/tests/gmp_operator_rhs_gmp_overflow.phpt
index e8b6139ace0..4fb1b3e2395 100644
--- a/ext/gmp/tests/gmp_operator_rhs_gmp_overflow.phpt
+++ b/ext/gmp/tests/gmp_operator_rhs_gmp_overflow.phpt
@@ -9,25 +9,25 @@
 try {
     var_dump(gmp_init(2) ** $too_large);
 } catch (ValueError $e) {
-    echo $e->getMessage(), PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_init(2) << $too_large);
 } catch (ValueError $e) {
-    echo $e->getMessage(), PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_init(2) >> $too_large);
 } catch (ValueError $e) {
-    echo $e->getMessage(), PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECTF--
-Exponent must be between 0 and %d
-Shift must be between 0 and %d
-Shift must be between 0 and %d
+ValueError: Exponent must be between 0 and %d
+ValueError: Shift must be between 0 and %d
+ValueError: Shift must be between 0 and %d
 Done
diff --git a/ext/gmp/tests/gmp_or.phpt b/ext/gmp/tests/gmp_or.phpt
index a51a06a09ca..2cbbecba1c0 100644
--- a/ext/gmp/tests/gmp_or.phpt
+++ b/ext/gmp/tests/gmp_or.phpt
@@ -14,7 +14,7 @@
 try {
     var_dump(gmp_strval(gmp_or("test", "no test")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $n = gmp_init("987657876543456");
@@ -25,17 +25,17 @@
 try {
     var_dump(gmp_or(array(), 1));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_or(1, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_or(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -46,10 +46,10 @@
 string(10) "2342341163"
 string(2) "-1"
 string(3) "-19"
-gmp_or(): Argument #1 ($num1) is not an integer string
+ValueError: gmp_or(): Argument #1 ($num1) is not an integer string
 string(15) "987657876576252"
 string(21) "987658441719689394144"
-gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_or(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_or(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_or(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_perfect_square.phpt b/ext/gmp/tests/gmp_perfect_square.phpt
index 16fca508bff..b9b31050e71 100644
--- a/ext/gmp/tests/gmp_perfect_square.phpt
+++ b/ext/gmp/tests/gmp_perfect_square.phpt
@@ -24,7 +24,7 @@
 try {
     var_dump(gmp_perfect_square(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -41,5 +41,5 @@
 bool(false)
 bool(true)
 bool(false)
-gmp_perfect_square(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_perfect_square(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_popcount.phpt b/ext/gmp/tests/gmp_popcount.phpt
index 3b61eec5b7a..3b15a659c5e 100644
--- a/ext/gmp/tests/gmp_popcount.phpt
+++ b/ext/gmp/tests/gmp_popcount.phpt
@@ -16,7 +16,7 @@
 try {
     var_dump(gmp_popcount(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -28,5 +28,5 @@
 int(31)
 int(-1)
 int(20)
-gmp_popcount(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_popcount(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_pow.phpt b/ext/gmp/tests/gmp_pow.phpt
index 36d0d16d8cc..ae206e3a7fc 100644
--- a/ext/gmp/tests/gmp_pow.phpt
+++ b/ext/gmp/tests/gmp_pow.phpt
@@ -13,7 +13,7 @@
 try {
     gmp_pow("2", -1);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 var_dump(gmp_strval(gmp_pow("-2",10)));
 var_dump(gmp_strval(gmp_pow(20,10)));
@@ -21,7 +21,7 @@
 try {
     gmp_pow(50,-5);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 $n = gmp_init("20");
@@ -32,13 +32,13 @@
 try {
     var_dump(gmp_pow(2,array()));
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 try {
     var_dump(gmp_pow(array(),10));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -49,13 +49,13 @@
 string(5) "-2048"
 string(4) "1024"
 string(1) "1"
-gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
+ValueError: gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
 string(4) "1024"
 string(14) "10240000000000"
 string(17) "97656250000000000"
-gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
+ValueError: gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
 string(14) "10240000000000"
 string(14) "10240000000000"
-gmp_pow(): Argument #2 ($exponent) must be of type int, array given
-gmp_pow(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_pow(): Argument #2 ($exponent) must be of type int, array given
+TypeError: gmp_pow(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_pow2.phpt b/ext/gmp/tests/gmp_pow2.phpt
index 96f33e8c25c..5902e00a3d2 100644
--- a/ext/gmp/tests/gmp_pow2.phpt
+++ b/ext/gmp/tests/gmp_pow2.phpt
@@ -12,13 +12,13 @@
 try {
     pow($n, -10);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 try {
     $n ** -10;
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 ?>
@@ -31,5 +31,5 @@
   ["num"]=>
   string(4) "1024"
 }
-Exponent must be between 0 and %d
-Exponent must be between 0 and %d
+ValueError: Exponent must be between 0 and %d
+ValueError: Exponent must be between 0 and %d
diff --git a/ext/gmp/tests/gmp_powm_sec.phpt b/ext/gmp/tests/gmp_powm_sec.phpt
index 2c66ff25a5e..1ec9bbb0319 100644
--- a/ext/gmp/tests/gmp_powm_sec.phpt
+++ b/ext/gmp/tests/gmp_powm_sec.phpt
@@ -18,20 +18,20 @@
     try {
         var_dump(gmp_powm_sec(4, $exp, 497));
     } catch (\ValueError $e) {
-        echo $e::class, ": ", $e->getMessage(), \PHP_EOL;
+        echo $e::class, ': ', $e->getMessage(), PHP_EOL;
     }
 }

 try {
     var_dump(gmp_powm_sec(4, 13, 0));
 } catch (\DivisionByZeroError $e) {
-    echo $e::class, ": ", $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_powm_sec(4, 13, 496));
 } catch (\ValueError $e) {
-    echo $e::class, ": ", $e->getMessage(), \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
diff --git a/ext/gmp/tests/gmp_pown.phpt b/ext/gmp/tests/gmp_pown.phpt
index 79709f27271..92d20fd5ed7 100644
--- a/ext/gmp/tests/gmp_pown.phpt
+++ b/ext/gmp/tests/gmp_pown.phpt
@@ -22,40 +22,40 @@
 try {
     var_dump(gmp_powm(5, 11, 0));
 } catch (\DivisionByZeroError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_powm(5, "11", gmp_init(0)));
 } catch (\DivisionByZeroError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_powm(array(),$e,$m));
 } catch (\TypeError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_powm($n,array(),$m));
 } catch (\TypeError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_powm($n,$error,array()));
 } catch (\TypeError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_powm(array(),array(),array()));
 } catch (\TypeError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }

 try {
     $n = gmp_init("-5");
     var_dump(gmp_powm(10, $n, 10));
 } catch (\ValueError $error) {
-    echo $error->getMessage() . \PHP_EOL;
+    echo $error::class, ': ', $error->getMessage(), PHP_EOL;
 }

 $n = gmp_init("0");
@@ -73,13 +73,13 @@
 string(3) "331"
 string(3) "171"
 string(3) "371"
-gmp_powm(): Argument #3 ($modulus) Modulo by zero
-gmp_powm(): Argument #3 ($modulus) Modulo by zero
-gmp_powm(): Argument #1 ($num) must be of type GMP|string|int, array given
-gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, array given
-gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, TypeError given
-gmp_powm(): Argument #1 ($num) must be of type GMP|string|int, array given
-gmp_powm(): Argument #2 ($exponent) must be greater than or equal to 0
+DivisionByZeroError: gmp_powm(): Argument #3 ($modulus) Modulo by zero
+DivisionByZeroError: gmp_powm(): Argument #3 ($modulus) Modulo by zero
+TypeError: gmp_powm(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, array given
+TypeError: gmp_powm(): Argument #2 ($exponent) must be of type GMP|string|int, TypeError given
+TypeError: gmp_powm(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_powm(): Argument #2 ($exponent) must be greater than or equal to 0
 object(GMP)#6 (1) {
   ["num"]=>
   string(1) "1"
diff --git a/ext/gmp/tests/gmp_prevprime.phpt b/ext/gmp/tests/gmp_prevprime.phpt
index 541a62f918d..117d7573d83 100644
--- a/ext/gmp/tests/gmp_prevprime.phpt
+++ b/ext/gmp/tests/gmp_prevprime.phpt
@@ -15,7 +15,7 @@
     try {
         var_dump(gmp_prevprime($value));
     } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+        echo $e::class, ': ', $e->getMessage(), PHP_EOL;
     }
 }

@@ -23,7 +23,7 @@
 try {
     var_dump(gmp_prevprime(2, $definitelyPrime));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump($definitelyPrime);

@@ -44,11 +44,11 @@

 ?>
 --EXPECT--
-gmp_prevprime(): Argument #1 ($num) must be greater than 2
-gmp_prevprime(): Argument #1 ($num) must be greater than 2
-gmp_prevprime(): Argument #1 ($num) must be greater than 2
-gmp_prevprime(): Argument #1 ($num) must be greater than 2
-gmp_prevprime(): Argument #1 ($num) must be greater than 2
+ValueError: gmp_prevprime(): Argument #1 ($num) must be greater than 2
+ValueError: gmp_prevprime(): Argument #1 ($num) must be greater than 2
+ValueError: gmp_prevprime(): Argument #1 ($num) must be greater than 2
+ValueError: gmp_prevprime(): Argument #1 ($num) must be greater than 2
+ValueError: gmp_prevprime(): Argument #1 ($num) must be greater than 2
 NULL
 string(1) "2"
 string(1) "3"
diff --git a/ext/gmp/tests/gmp_prob_prime.phpt b/ext/gmp/tests/gmp_prob_prime.phpt
index 7c93a48bd93..9a962613b4d 100644
--- a/ext/gmp/tests/gmp_prob_prime.phpt
+++ b/ext/gmp/tests/gmp_prob_prime.phpt
@@ -31,7 +31,7 @@
 try {
     var_dump(gmp_prob_prime(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -75,5 +75,5 @@
 int(0)
 int(0)
 int(0)
-gmp_prob_prime(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_prob_prime(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_random_bits.phpt b/ext/gmp/tests/gmp_random_bits.phpt
index 4e7f3379838..55693814fed 100644
--- a/ext/gmp/tests/gmp_random_bits.phpt
+++ b/ext/gmp/tests/gmp_random_bits.phpt
@@ -8,12 +8,12 @@
 try {
     var_dump(gmp_random_bits(0));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_random_bits(-1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 // If these error the test fails.
@@ -41,6 +41,6 @@
 echo "Done\n";
 ?>
 --EXPECTF--
-gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
-gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
+ValueError: gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
+ValueError: gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d
 Done
diff --git a/ext/gmp/tests/gmp_random_range.phpt b/ext/gmp/tests/gmp_random_range.phpt
index 59ac5762fce..9882bf4ffa3 100644
--- a/ext/gmp/tests/gmp_random_range.phpt
+++ b/ext/gmp/tests/gmp_random_range.phpt
@@ -12,18 +12,18 @@
 try {
     var_dump(gmp_random_range(10, -10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 try {
     var_dump(gmp_random_range($plusTen, $minusTen));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_random_range($plusTen, $zero));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 // If these error the test fails.
@@ -74,7 +74,7 @@
 echo "Done\n";
 ?>
 --EXPECT--
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
+ValueError: gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
+ValueError: gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
+ValueError: gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
 Done
diff --git a/ext/gmp/tests/gmp_random_seed.phpt b/ext/gmp/tests/gmp_random_seed.phpt
index bfb45739f54..71b25dbf372 100644
--- a/ext/gmp/tests/gmp_random_seed.phpt
+++ b/ext/gmp/tests/gmp_random_seed.phpt
@@ -110,7 +110,7 @@
 try {
     var_dump(gmp_random_seed('not a number'));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }


@@ -173,5 +173,5 @@
 string(4) "9636"
 string(5) "-9848"
 string(5) "-9648"
-gmp_random_seed(): Argument #1 ($seed) is not an integer string
+ValueError: gmp_random_seed(): Argument #1 ($seed) is not an integer string
 Done
diff --git a/ext/gmp/tests/gmp_remroot.phpt b/ext/gmp/tests/gmp_remroot.phpt
index fe7a8316e59..8bf0a1b4a7f 100644
--- a/ext/gmp/tests/gmp_remroot.phpt
+++ b/ext/gmp/tests/gmp_remroot.phpt
@@ -14,7 +14,7 @@
 try {
     var_dump(gmp_rootrem(-100, 4));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_rootrem(0, 3));
@@ -22,12 +22,12 @@
 try {
     var_dump(gmp_rootrem(100, 0));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_rootrem(100, -3));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
@@ -92,7 +92,7 @@
     string(2) "19"
   }
 }
-gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
+ValueError: gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
 array(2) {
   [0]=>
   object(GMP)#%d (1) {
@@ -105,5 +105,5 @@
     string(1) "0"
   }
 }
-gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
-gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
+ValueError: gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
+ValueError: gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
diff --git a/ext/gmp/tests/gmp_root.phpt b/ext/gmp/tests/gmp_root.phpt
index b4a88405a21..3134d5b8e6a 100644
--- a/ext/gmp/tests/gmp_root.phpt
+++ b/ext/gmp/tests/gmp_root.phpt
@@ -15,7 +15,7 @@
 try {
     var_dump(gmp_root(-100, 4));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_root(0, 3));
@@ -23,12 +23,12 @@
 try {
     var_dump(gmp_root(100, 0));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_root(100, -3));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 ?>
@@ -53,10 +53,10 @@
   ["num"]=>
   string(1) "3"
 }
-gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
+ValueError: gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
 object(GMP)#%d (1) {
   ["num"]=>
   string(1) "0"
 }
-gmp_root(): Argument #2 ($nth) must be between 1 and %d
-gmp_root(): Argument #2 ($nth) must be between 1 and %d
+ValueError: gmp_root(): Argument #2 ($nth) must be between 1 and %d
+ValueError: gmp_root(): Argument #2 ($nth) must be between 1 and %d
diff --git a/ext/gmp/tests/gmp_scan0.phpt b/ext/gmp/tests/gmp_scan0.phpt
index 3accf37eee1..982f2b67410 100644
--- a/ext/gmp/tests/gmp_scan0.phpt
+++ b/ext/gmp/tests/gmp_scan0.phpt
@@ -8,7 +8,7 @@
 try {
     var_dump(gmp_scan0("434234", -10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_scan0("434234", 1));
@@ -22,17 +22,17 @@
 try {
     var_dump(gmp_scan0(array(), 200));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECTF--
-gmp_scan0(): Argument #2 ($start) must be between 0 and %d * %d
+ValueError: gmp_scan0(): Argument #2 ($start) must be between 0 and %d * %d
 int(2)
 int(0)
 int(5)
 int(200)
 int(13)
-gmp_scan0(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_scan0(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_scan1.phpt b/ext/gmp/tests/gmp_scan1.phpt
index 8021f7e679d..83a70bcba26 100644
--- a/ext/gmp/tests/gmp_scan1.phpt
+++ b/ext/gmp/tests/gmp_scan1.phpt
@@ -8,7 +8,7 @@
 try {
     var_dump(gmp_scan1("434234", -10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_scan1("434234", 1));
@@ -22,17 +22,17 @@
 try {
     var_dump(gmp_scan1(array(), 200));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECTF--
-gmp_scan1(): Argument #2 ($start) must be between 0 and %d * %d
+ValueError: gmp_scan1(): Argument #2 ($start) must be between 0 and %d * %d
 int(1)
 int(12)
 int(9)
 int(-1)
 int(10)
-gmp_scan1(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_scan1(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_setbit.phpt b/ext/gmp/tests/gmp_setbit.phpt
index 775042ef973..09ce16ada7f 100644
--- a/ext/gmp/tests/gmp_setbit.phpt
+++ b/ext/gmp/tests/gmp_setbit.phpt
@@ -13,7 +13,7 @@
 try {
     gmp_setbit($n, -20, false);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval($n));

@@ -39,26 +39,26 @@
 try {
     gmp_setbit($b, 23);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $a = array();
 try {
     gmp_setbit($a, array());
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 echo "Done\n";
 ?>
 --EXPECTF--
 string(2) "-1"
-gmp_setbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_setbit(): Argument #2 ($index) must be between 0 and %d * %d
 string(1) "5"
 string(1) "1"
 string(1) "7"
 string(12) "100008388608"
 string(12) "100000000000"
 string(12) "100000000008"
-gmp_setbit(): Argument #1 ($num) must be of type GMP, string given
-gmp_setbit(): Argument #1 ($num) must be of type GMP, array given
+TypeError: gmp_setbit(): Argument #1 ($num) must be of type GMP, string given
+TypeError: gmp_setbit(): Argument #1 ($num) must be of type GMP, array given
 Done
diff --git a/ext/gmp/tests/gmp_setbit_long.phpt b/ext/gmp/tests/gmp_setbit_long.phpt
index bbd472de967..e6d2dc262d5 100644
--- a/ext/gmp/tests/gmp_setbit_long.phpt
+++ b/ext/gmp/tests/gmp_setbit_long.phpt
@@ -30,7 +30,7 @@
     try {
         gmp_setbit($n, $i, 1);
     } catch (\ValueError $e) {
-        echo $e->getMessage() . \PHP_EOL;
+        echo $e::class, ': ', $e->getMessage(), PHP_EOL;
     }
 }
 echo "Done\n";
@@ -41,5 +41,5 @@
 3FFFFFFFF
 FFFFFFFFF
 3FFFFFFFFF
-gmp_setbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_setbit(): Argument #2 ($index) must be between 0 and %d * %d
 Done
diff --git a/ext/gmp/tests/gmp_sign.phpt b/ext/gmp/tests/gmp_sign.phpt
index 56706b20eda..7b1dba970fd 100644
--- a/ext/gmp/tests/gmp_sign.phpt
+++ b/ext/gmp/tests/gmp_sign.phpt
@@ -14,18 +14,18 @@
 try {
     var_dump(gmp_sign("+34534573457345"));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     $n = gmp_init("098909878976786545");
     var_dump(gmp_sign($n));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_sign(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -36,7 +36,7 @@
 int(0)
 int(1)
 int(-1)
-gmp_sign(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_sign(): Argument #1 ($num) must be of type GMP|string|int, array given
+ValueError: gmp_sign(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+TypeError: gmp_sign(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_sqrt.phpt b/ext/gmp/tests/gmp_sqrt.phpt
index 50da298161c..52a13a3d3ff 100644
--- a/ext/gmp/tests/gmp_sqrt.phpt
+++ b/ext/gmp/tests/gmp_sqrt.phpt
@@ -8,12 +8,12 @@
 try {
     var_dump(gmp_strval(gmp_sqrt(-2)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval(gmp_sqrt("-2")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_strval(gmp_sqrt("0")));
@@ -26,7 +26,7 @@
 try {
     var_dump(gmp_strval(gmp_sqrt($n)));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 $n = gmp_init(777);
 var_dump(gmp_strval(gmp_sqrt($n)));
@@ -34,19 +34,19 @@
 try {
     var_dump(gmp_sqrt(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECT--
-gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
-gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
+ValueError: gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
+ValueError: gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
 string(1) "0"
 string(1) "1"
 string(2) "12"
 string(1) "0"
-gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
+ValueError: gmp_sqrt(): Argument #1 ($num) must be greater than or equal to 0
 string(2) "27"
-gmp_sqrt(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_sqrt(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_sqrtrem.phpt b/ext/gmp/tests/gmp_sqrtrem.phpt
index 915fc4ed2f9..a9602b64089 100644
--- a/ext/gmp/tests/gmp_sqrtrem.phpt
+++ b/ext/gmp/tests/gmp_sqrtrem.phpt
@@ -9,7 +9,7 @@
     $r = gmp_sqrtrem(-1);
     var_dump($r);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $r = gmp_sqrtrem("0");
@@ -49,7 +49,7 @@
     $r = gmp_sqrtrem($n);
     var_dump($r);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $n = gmp_init(1000001);
@@ -60,13 +60,13 @@
 try {
     var_dump(gmp_sqrtrem(array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECT--
-gmp_sqrtrem(): Argument #1 ($num) must be greater than or equal to 0
+ValueError: gmp_sqrtrem(): Argument #1 ($num) must be greater than or equal to 0
 string(1) "0"
 string(1) "0"
 string(1) "1"
@@ -83,8 +83,8 @@
 string(1) "0"
 string(4) "1000"
 string(1) "1"
-gmp_sqrtrem(): Argument #1 ($num) must be greater than or equal to 0
+ValueError: gmp_sqrtrem(): Argument #1 ($num) must be greater than or equal to 0
 string(4) "1000"
 string(1) "1"
-gmp_sqrtrem(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_sqrtrem(): Argument #1 ($num) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/gmp_strict_types.phpt b/ext/gmp/tests/gmp_strict_types.phpt
index 006f06465c5..3e11b0d095e 100644
--- a/ext/gmp/tests/gmp_strict_types.phpt
+++ b/ext/gmp/tests/gmp_strict_types.phpt
@@ -13,27 +13,27 @@
 try {
     gmp_abs(1.0);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     gmp_abs(false);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     gmp_abs(true);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     gmp_abs(null);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     gmp_abs([]);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }

 ?>
@@ -50,8 +50,8 @@
   ["num"]=>
   string(1) "1"
 }
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, false given
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, true given
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, null given
-gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, float given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, false given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, true given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, null given
+TypeError: gmp_abs(): Argument #1 ($num) must be of type GMP|string|int, array given
diff --git a/ext/gmp/tests/gmp_strval.phpt b/ext/gmp/tests/gmp_strval.phpt
index 1221d04b3b1..771c0e20301 100644
--- a/ext/gmp/tests/gmp_strval.phpt
+++ b/ext/gmp/tests/gmp_strval.phpt
@@ -8,19 +8,19 @@
 try {
     var_dump(gmp_strval(""));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval("", -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $fp = fopen(__FILE__, "r");
 try {
     var_dump(gmp_strval($fp));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $g = gmp_init("9765456");
@@ -28,12 +28,12 @@
 try {
     var_dump(gmp_strval($g, -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval($g, 100000));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval($g, 10));

@@ -42,40 +42,40 @@
 try {
     var_dump(gmp_strval($g, -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval($g, 100000));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 var_dump(gmp_strval($g, 10));

 try {
     var_dump(gmp_strval(array(1,2)));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_strval(new stdclass));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECT--
-gmp_strval(): Argument #1 ($num) is not an integer string
-gmp_strval(): Argument #1 ($num) is not an integer string
-gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, resource given
+ValueError: gmp_strval(): Argument #1 ($num) is not an integer string
+ValueError: gmp_strval(): Argument #1 ($num) is not an integer string
+TypeError: gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, resource given
 string(7) "9765456"
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
 string(7) "9765456"
 string(8) "-3373333"
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
-gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
+ValueError: gmp_strval(): Argument #2 ($base) must be between 2 and 62, or -2 and -36
 string(8) "-3373333"
-gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, array given
-gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
+TypeError: gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, array given
+TypeError: gmp_strval(): Argument #1 ($num) must be of type GMP|string|int, stdClass given
 Done
diff --git a/ext/gmp/tests/gmp_sub.phpt b/ext/gmp/tests/gmp_sub.phpt
index 5161bce1035..9cbf2097cc3 100644
--- a/ext/gmp/tests/gmp_sub.phpt
+++ b/ext/gmp/tests/gmp_sub.phpt
@@ -8,12 +8,12 @@
 try {
     var_dump(gmp_sub("", ""));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_sub(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump($g = gmp_sub(10000, 10001));
@@ -25,20 +25,20 @@
     var_dump($g = gmp_sub(10000, new stdclass));
     var_dump(gmp_strval($g));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump($g = gmp_sub(new stdclass, 100));
     var_dump(gmp_strval($g));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
 ?>
 --EXPECT--
-gmp_sub(): Argument #1 ($num1) is not an integer string
-gmp_sub(): Argument #1 ($num1) must be of type GMP|string|int, array given
+ValueError: gmp_sub(): Argument #1 ($num1) is not an integer string
+TypeError: gmp_sub(): Argument #1 ($num1) must be of type GMP|string|int, array given
 object(GMP)#1 (1) {
   ["num"]=>
   string(2) "-1"
@@ -49,6 +49,6 @@
   string(5) "10001"
 }
 string(5) "10001"
-gmp_sub(): Argument #2 ($num2) must be of type GMP|string|int, stdClass given
-gmp_sub(): Argument #1 ($num1) must be of type GMP|string|int, stdClass given
+TypeError: gmp_sub(): Argument #2 ($num2) must be of type GMP|string|int, stdClass given
+TypeError: gmp_sub(): Argument #1 ($num1) must be of type GMP|string|int, stdClass given
 Done
diff --git a/ext/gmp/tests/gmp_testbit.phpt b/ext/gmp/tests/gmp_testbit.phpt
index 1cef8cd4166..fb6497df546 100644
--- a/ext/gmp/tests/gmp_testbit.phpt
+++ b/ext/gmp/tests/gmp_testbit.phpt
@@ -10,7 +10,7 @@
 try {
     var_dump(gmp_testbit($n, -10));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump(gmp_testbit($n, 0));
@@ -22,7 +22,7 @@
 try {
     var_dump(gmp_testbit($n, -1));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $n = gmp_init("1000000");
@@ -48,12 +48,12 @@
 echo "Done\n";
 ?>
 --EXPECTF--
-gmp_testbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_testbit(): Argument #2 ($index) must be between 0 and %d * %d
 bool(false)
 bool(false)
 bool(false)
 bool(true)
-gmp_testbit(): Argument #2 ($index) must be between 0 and %d * %d
+ValueError: gmp_testbit(): Argument #2 ($index) must be between 0 and %d * %d
 bool(false)
 bool(true)
 string(7) "1000002"
diff --git a/ext/gmp/tests/gmp_xor.phpt b/ext/gmp/tests/gmp_xor.phpt
index fdc8a67562c..a60500147ca 100644
--- a/ext/gmp/tests/gmp_xor.phpt
+++ b/ext/gmp/tests/gmp_xor.phpt
@@ -14,7 +14,7 @@
 try {
     var_dump(gmp_strval(gmp_xor("test", "no test")));
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $n = gmp_init("987657876543456");
@@ -25,17 +25,17 @@
 try {
     var_dump(gmp_xor(array(), 1));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_xor(1, array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 try {
     var_dump(gmp_xor(array(), array()));
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 echo "Done\n";
@@ -46,10 +46,10 @@
 string(10) "2342340648"
 string(5) "-3334"
 string(5) "-4563"
-gmp_xor(): Argument #1 ($num1) is not an integer string
+ValueError: gmp_xor(): Argument #1 ($num1) is not an integer string
 string(15) "987657876574716"
 string(21) "987658017016065701376"
-gmp_xor(): Argument #1 ($num1) must be of type GMP|string|int, array given
-gmp_xor(): Argument #2 ($num2) must be of type GMP|string|int, array given
-gmp_xor(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_xor(): Argument #1 ($num1) must be of type GMP|string|int, array given
+TypeError: gmp_xor(): Argument #2 ($num2) must be of type GMP|string|int, array given
+TypeError: gmp_xor(): Argument #1 ($num1) must be of type GMP|string|int, array given
 Done
diff --git a/ext/gmp/tests/overloading.phpt b/ext/gmp/tests/overloading.phpt
index f55a83f0bd5..7d078784e2f 100644
--- a/ext/gmp/tests/overloading.phpt
+++ b/ext/gmp/tests/overloading.phpt
@@ -26,7 +26,7 @@
 try {
     var_dump($a / 0);
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump($a % $b);
@@ -35,7 +35,7 @@
 try {
     var_dump($a % 0);
 } catch (\DivisionByZeroError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 var_dump($a ** $b);
@@ -64,13 +64,13 @@
 try {
     $a << -1;
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 try {
     $a >> -1;
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }

 var_dump(~$a);
@@ -97,7 +97,7 @@
 try {
     var_dump($a == new stdClass);
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }

 $a += 1;
@@ -172,7 +172,7 @@
   ["num"]=>
   string(1) "2"
 }
-Division by zero
+DivisionByZeroError: Division by zero
 object(GMP)#4 (1) {
   ["num"]=>
   string(1) "8"
@@ -185,7 +185,7 @@
   ["num"]=>
   string(1) "8"
 }
-Modulo by zero
+DivisionByZeroError: Modulo by zero
 object(GMP)#3 (1) {
   ["num"]=>
   string(28) "3937657486715347520027492352"
@@ -254,8 +254,8 @@
   ["num"]=>
   string(3) "-11"
 }
-Shift must be between 0 and %d
-Shift must be between 0 and %d
+ValueError: Shift must be between 0 and %d
+ValueError: Shift must be between 0 and %d
 object(GMP)#5 (1) {
   ["num"]=>
   string(3) "-43"
@@ -282,7 +282,7 @@
 bool(true)
 bool(false)
 bool(true)
-Number must be of type GMP|string|int, stdClass given
+TypeError: Number must be of type GMP|string|int, stdClass given
 object(GMP)#4 (1) {
   ["num"]=>
   string(2) "43"
diff --git a/ext/gmp/tests/serialize.phpt b/ext/gmp/tests/serialize.phpt
index 84877459a9b..3926a1eb284 100644
--- a/ext/gmp/tests/serialize.phpt
+++ b/ext/gmp/tests/serialize.phpt
@@ -18,27 +18,27 @@

 try {
     unserialize('C:3:"GMP":0:{}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 try {
     unserialize('C:3:"GMP":9:{s:2:"42";}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 try {
     unserialize('O:3:"GMP":0:{}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 try {
     unserialize('O:3:"GMP":1:{i:0;i:0;}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 try {
     unserialize('O:3:"GMP":1:{i:0;s:0:"";}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 try {
     unserialize('O:3:"GMP":2:{i:0;s:1:"0";i:1;i:0;}');
-} catch (Exception $e) { var_dump($e->getMessage()); }
+} catch (Exception $e) { echo $e::class, ': ', $e->getMessage(), "\n"; }

 ?>
 --EXPECTF--
@@ -66,9 +66,9 @@
   ["num"]=>
   string(2) "42"
 }
-string(28) "Could not unserialize number"
-string(32) "Could not unserialize properties"
-string(28) "Could not unserialize number"
-string(28) "Could not unserialize number"
-string(28) "Could not unserialize number"
-string(32) "Could not unserialize properties"
+Exception: Could not unserialize number
+Exception: Could not unserialize properties
+Exception: Could not unserialize number
+Exception: Could not unserialize number
+Exception: Could not unserialize number
+Exception: Could not unserialize properties
diff --git a/ext/gmp/tests/surprising_integer_literals.phpt b/ext/gmp/tests/surprising_integer_literals.phpt
index a4578f7afb5..dd5a2540d07 100644
--- a/ext/gmp/tests/surprising_integer_literals.phpt
+++ b/ext/gmp/tests/surprising_integer_literals.phpt
@@ -19,15 +19,15 @@
     try {
         var_dump(gmp_init($value));
     } catch (\ValueError $e) {
-        echo $e->getMessage(), \PHP_EOL;
+        echo $e::class, ': ', $e->getMessage(), PHP_EOL;
     }
 }
 ?>
 --EXPECT--
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
-gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string
+ValueError: gmp_init(): Argument #1 ($num) is not an integer string