[PHP-CVS] [php-src] master: ext/gmp: applied fixers to improve test robustness (#22987)

[email protected] (NickSdot via GitHub) Sat, 1 Aug 2026 22:06:17 +0000
Newsgroups php.cvs
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-08-01T23:06:14+01:00

Commit: https://github.com/php/php-src/commit/b74e0f749d23d170e714f4b33f0ac882635a53f9
Raw diff: https://github.com/php/php-src/commit/b74e0f749d23d170e714f4b33f0ac882635a53f9.diff

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

Changed paths:
  M  ext/gmp/tests/003.phpt
  M  ext/gmp/tests/bug32773.phpt
  M  ext/gmp/tests/bug50283.phpt
  M  ext/gmp/tests/bug66872.phpt
  M  ext/gmp/tests/bug80560.phpt
  M  ext/gmp/tests/bug81119.phpt
  M  ext/gmp/tests/comparison_invalid.phpt
  M  ext/gmp/tests/construct.phpt
  M  ext/gmp/tests/gh16501.phpt
  M  ext/gmp/tests/gh9308.phpt
  M  ext/gmp/tests/gmp_abs.phpt
  M  ext/gmp/tests/gmp_and.phpt
  M  ext/gmp/tests/gmp_binomial.phpt
  M  ext/gmp/tests/gmp_clrbit.phpt
  M  ext/gmp/tests/gmp_cmp.phpt
  M  ext/gmp/tests/gmp_com.phpt
  M  ext/gmp/tests/gmp_div_q.phpt
  M  ext/gmp/tests/gmp_div_qr.phpt
  M  ext/gmp/tests/gmp_div_r.phpt
  M  ext/gmp/tests/gmp_divexact.phpt
  M  ext/gmp/tests/gmp_export.phpt
  M  ext/gmp/tests/gmp_fact.phpt
  M  ext/gmp/tests/gmp_fact_overflow.phpt
  M  ext/gmp/tests/gmp_gcdext.phpt
  M  ext/gmp/tests/gmp_hamdist.phpt
  M  ext/gmp/tests/gmp_import.phpt
  M  ext/gmp/tests/gmp_init.phpt
  M  ext/gmp/tests/gmp_intval.phpt
  M  ext/gmp/tests/gmp_invert.phpt
  M  ext/gmp/tests/gmp_jacobi.phpt
  M  ext/gmp/tests/gmp_legendre.phpt
  M  ext/gmp/tests/gmp_mod.phpt
  M  ext/gmp/tests/gmp_neg.phpt
  M  ext/gmp/tests/gmp_nextprime.phpt
  M  ext/gmp/tests/gmp_null_bytes.phpt
  M  ext/gmp/tests/gmp_operator_rhs_gmp_overflow.phpt
  M  ext/gmp/tests/gmp_or.phpt
  M  ext/gmp/tests/gmp_perfect_square.phpt
  M  ext/gmp/tests/gmp_popcount.phpt
  M  ext/gmp/tests/gmp_pow.phpt
  M  ext/gmp/tests/gmp_pow2.phpt
  M  ext/gmp/tests/gmp_powm_sec.phpt
  M  ext/gmp/tests/gmp_pown.phpt
  M  ext/gmp/tests/gmp_prevprime.phpt
  M  ext/gmp/tests/gmp_prob_prime.phpt
  M  ext/gmp/tests/gmp_random_bits.phpt
  M  ext/gmp/tests/gmp_random_range.phpt
  M  ext/gmp/tests/gmp_random_seed.phpt
  M  ext/gmp/tests/gmp_remroot.phpt
  M  ext/gmp/tests/gmp_root.phpt
  M  ext/gmp/tests/gmp_scan0.phpt
  M  ext/gmp/tests/gmp_scan1.phpt
  M  ext/gmp/tests/gmp_setbit.phpt
  M  ext/gmp/tests/gmp_setbit_long.phpt
  M  ext/gmp/tests/gmp_sign.phpt
  M  ext/gmp/tests/gmp_sqrt.phpt
  M  ext/gmp/tests/gmp_sqrtrem.phpt
  M  ext/gmp/tests/gmp_strict_types.phpt
  M  ext/gmp/tests/gmp_strval.phpt
  M  ext/gmp/tests/gmp_sub.phpt
  M  ext/gmp/tests/gmp_testbit.phpt
  M  ext/gmp/tests/gmp_xor.phpt
  M  ext/gmp/tests/overloading.phpt
  M  ext/gmp/tests/serialize.phpt
  M  ext/gmp/tests/surprising_integer_literals.phpt


Diff:

diff --git a/ext/gmp/tests/003.phpt b/ext/gmp/tests/003.phpt
index 8fdd723e8c4e..df9fd229fd87 100644
--- a/ext/gmp/tests/003.phpt
+++ b/ext/gmp/tests/003.phpt
@@ -26,7 +26,7 @@ gmp
         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 @@ gmp
         }
 ?>
 --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 3df59e67faff..0f2b862897c0 100644
--- a/ext/gmp/tests/bug32773.phpt
+++ b/ext/gmp/tests/bug32773.phpt
@@ -10,17 +10,17 @@ echo '10 + "0" = ', gmp_strval(gmp_add(10, '0')), "\n";
 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 db0e456da0e1..5f1806e508fe 100644
--- a/ext/gmp/tests/bug50283.phpt
+++ b/ext/gmp/tests/bug50283.phpt
@@ -10,34 +10,34 @@ printf("Decimal: %s, 36-based: %s\n", gmp_strval($a), gmp_strval($a,36));
 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 3d65a910b784..67870c06752f 100644
--- a/ext/gmp/tests/bug66872.phpt
+++ b/ext/gmp/tests/bug66872.phpt
@@ -8,9 +8,9 @@ gmp
 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 85f4dff96be4..2788c51e35d0 100644
--- a/ext/gmp/tests/bug80560.phpt
+++ b/ext/gmp/tests/bug80560.phpt
@@ -72,24 +72,24 @@ echo 'Hexadecimal', \PHP_EOL;
 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 @@ echo "Done\n";
 --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 e689a7251f60..8747871b11a0 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 @@ test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + []);
 
 ?>
 --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 edf24e889b8e..46ea036eae2d 100644
--- a/ext/gmp/tests/comparison_invalid.phpt
+++ b/ext/gmp/tests/comparison_invalid.phpt
@@ -8,13 +8,13 @@ gmp
 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 1b23bd791edd..28957bc5eee1 100644
--- a/ext/gmp/tests/construct.phpt
+++ b/ext/gmp/tests/construct.phpt
@@ -12,17 +12,17 @@ var_dump(new GMP("12", 4));
 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 @@ object(GMP)#1 (1) {
   ["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 325be85d1917..351370ff1b7d 100644
--- a/ext/gmp/tests/gh16501.phpt
+++ b/ext/gmp/tests/gh16501.phpt
@@ -7,8 +7,8 @@ gmp
 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 af13b8bdf328..94295c8226c3 100644
--- a/ext/gmp/tests/gh9308.phpt
+++ b/ext/gmp/tests/gh9308.phpt
@@ -11,9 +11,9 @@ declare(strict_types=1);
 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 23fac5be5dee..0d75efc7ff52 100644
--- a/ext/gmp/tests/gmp_abs.phpt
+++ b/ext/gmp/tests/gmp_abs.phpt
@@ -8,14 +8,14 @@ gmp
 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 @@ try {
     // 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 f2356dc835a3..c5eff64fa26d 100644
--- a/ext/gmp/tests/gmp_and.phpt
+++ b/ext/gmp/tests/gmp_and.phpt
@@ -14,7 +14,7 @@ var_dump(gmp_strval(gmp_and(4545, -20)));
 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 @@ var_dump(gmp_strval(gmp_and($n, $n1)));
 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(5) "40994"
 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 1bf371e68a14..7cca4c7f5785 100644
--- a/ext/gmp/tests/gmp_binomial.phpt
+++ b/ext/gmp/tests/gmp_binomial.phpt
@@ -23,7 +23,7 @@ var_dump(gmp_binomial(-2, 6)); // == (2 + 6 - 1 over 6)
 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 @@ object(GMP)#2 (1) {
   ["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 afefa740f10e..9dc63a87f5a5 100644
--- a/ext/gmp/tests/gmp_clrbit.phpt
+++ b/ext/gmp/tests/gmp_clrbit.phpt
@@ -13,7 +13,7 @@ $n = gmp_init(-1);
 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 @@ $n = gmp_init("1000000");
 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 @@ $n = array();
 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 535d23cc4a20..8e5b68e801f8 100644
--- a/ext/gmp/tests/gmp_cmp.phpt
+++ b/ext/gmp/tests/gmp_cmp.phpt
@@ -30,7 +30,7 @@ var_dump(gmp_cmp($n1,$n) === 0);
 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 @@ gmp(1231222, 0): left greater than right
 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 344903a13c3e..5d92494c4bb6 100644
--- a/ext/gmp/tests/gmp_com.phpt
+++ b/ext/gmp/tests/gmp_com.phpt
@@ -10,7 +10,7 @@ var_dump(gmp_strval(gmp_com("0")));
 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 @@ var_dump(gmp_strval(gmp_com($n)));
 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 @@ echo "Done\n";
 --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 8d892c3ff0ad..d02db8db9eb3 100644
--- a/ext/gmp/tests/gmp_div_q.phpt
+++ b/ext/gmp/tests/gmp_div_q.phpt
@@ -10,14 +10,14 @@ var_dump(gmp_div_q(0,1));
 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 @@ $fp = fopen(__FILE__, 'r');
 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 @@ object(GMP)#1 (1) {
   ["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 @@ object(GMP)#1 (1) {
   ["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 f7649b0208c2..00234b5e635f 100644
--- a/ext/gmp/tests/gmp_div_qr.phpt
+++ b/ext/gmp/tests/gmp_div_qr.phpt
@@ -10,19 +10,19 @@ var_dump(gmp_div_qr(0,1));
 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 @@ $fp = fopen(__FILE__, 'r');
 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 @@ array(2) {
     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 @@ array(2) {
     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 @@ array(2) {
     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 501284ad47f8..124e07e05037 100644
--- a/ext/gmp/tests/gmp_div_r.phpt
+++ b/ext/gmp/tests/gmp_div_r.phpt
@@ -10,14 +10,14 @@ var_dump($r = gmp_div_r(0,1));
 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 @@ $fp = fopen(__FILE__, 'r');
 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 @@ object(GMP)#1 (1) {
   ["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 @@ object(GMP)#3 (1) {
   ["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 ecd7df4fef23..79cc481e513c 100644
--- a/ext/gmp/tests/gmp_divexact.phpt
+++ b/ext/gmp/tests/gmp_divexact.phpt
@@ -18,7 +18,7 @@ try {
     $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 @@ echo "Done\n";
 ?>
 --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 085bafbbcc3c..b8022fb1df0a 100644
--- a/ext/gmp/tests/gmp_export.phpt
+++ b/ext/gmp/tests/gmp_export.phpt
@@ -57,30 +57,30 @@ var_dump(bin2hex(gmp_export(0xff)));
 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 b28f572c6975..7ebdd5df72ed 100644
--- a/ext/gmp/tests/gmp_fact.phpt
+++ b/ext/gmp/tests/gmp_fact.phpt
@@ -9,18 +9,18 @@ var_dump(gmp_strval(gmp_fact(0)));
 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 @@ $n = gmp_init(-10);
 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 2d22005818c5..dd7984edaeae 100644
--- a/ext/gmp/tests/gmp_fact_overflow.phpt
+++ b/ext/gmp/tests/gmp_fact_overflow.phpt
@@ -8,18 +8,18 @@ gmp
 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 530e0cb24c98..cb6284a575ef 100644
--- a/ext/gmp/tests/gmp_gcdext.phpt
+++ b/ext/gmp/tests/gmp_gcdext.phpt
@@ -31,12 +31,12 @@ foreach ($a as $val) {
 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(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 26de0f5a46e3..aca4433d8a6f 100644
--- a/ext/gmp/tests/gmp_hamdist.phpt
+++ b/ext/gmp/tests/gmp_hamdist.phpt
@@ -19,17 +19,17 @@ var_dump(gmp_hamdist($n, $n1));
 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(-1)
 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 6292738b5544..781388c8b1b3 100644
--- a/ext/gmp/tests/gmp_import.phpt
+++ b/ext/gmp/tests/gmp_import.phpt
@@ -51,49 +51,49 @@ var_dump($passed);
 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 4032b54ba47e..a41e63ef54f3 100644
--- a/ext/gmp/tests/gmp_init.phpt
+++ b/ext/gmp/tests/gmp_init.phpt
@@ -10,23 +10,23 @@ var_dump(gmp_strval(gmp_init("98765678")));
 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 @@ object(GMP)#1 (1) {
   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 15a1cdcc3d83..310f4a03fe5f 100644
--- a/ext/gmp/tests/gmp_intval.phpt
+++ b/ext/gmp/tests/gmp_intval.phpt
@@ -16,22 +16,22 @@ var_dump(gmp_intval($g));
 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(-1)
 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 e2cd5c252abc..16dbd075e4da 100644
--- a/ext/gmp/tests/gmp_invert.phpt
+++ b/ext/gmp/tests/gmp_invert.phpt
@@ -11,14 +11,14 @@ var_dump(gmp_strval(gmp_invert("12312323213123123",7624)));
 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 @@ var_dump(gmp_strval(gmp_invert($n1, $n)));
 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 @@ echo "Done\n";
 --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)
 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 59fab662fa83..d28847a4655a 100644
--- a/ext/gmp/tests/gmp_jacobi.phpt
+++ b/ext/gmp/tests/gmp_jacobi.phpt
@@ -23,17 +23,17 @@ var_dump(gmp_strval(gmp_jacobi(3, $n1)));
 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(1) "0"
 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 4955558281d0..fa3b2e05ad51 100644
--- a/ext/gmp/tests/gmp_legendre.phpt
+++ b/ext/gmp/tests/gmp_legendre.phpt
@@ -23,17 +23,17 @@ var_dump(gmp_strval(gmp_legendre(3, $n1)));
 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(1) "0"
 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 af2e5936d5cf..f66edaeb10e7 100644
--- a/ext/gmp/tests/gmp_mod.phpt
+++ b/ext/gmp/tests/gmp_mod.phpt
@@ -8,7 +8,7 @@ gmp
 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 @@ var_dump(gmp_mod(0,-1));
 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 @@ var_dump(gmp_mod($a, $b));
 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 @@ object(GMP)#2 (1) {
   ["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 6a7177a6ed35..1f48c3cc7cf1 100644
--- a/ext/gmp/tests/gmp_neg.phpt
+++ b/ext/gmp/tests/gmp_neg.phpt
@@ -13,7 +13,7 @@ var_dump(gmp_intval(gmp_neg("-1")));
 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 @@ var_dump(gmp_strval(gmp_neg($n)));
 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(0)
 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 b907d7a84e99..6a6fb565e7d6 100644
--- a/ext/gmp/tests/gmp_nextprime.phpt
+++ b/ext/gmp/tests/gmp_nextprime.phpt
@@ -19,19 +19,19 @@ try {
     $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(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 1518d342dda2..910d754fa8bc 100644
--- a/ext/gmp/tests/gmp_null_bytes.phpt
+++ b/ext/gmp/tests/gmp_null_bytes.phpt
@@ -16,13 +16,13 @@ foreach ($tests as $label => $test) {
     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 e8b6139ace0f..4fb1b3e23952 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 @@ $too_large = gmp_init("18446744073709551616");
 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 a51a06a09cad..2cbbecba1c0a 100644
--- a/ext/gmp/tests/gmp_or.phpt
+++ b/ext/gmp/tests/gmp_or.phpt
@@ -14,7 +14,7 @@ var_dump(gmp_strval(gmp_or(4545, -20)));
 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 @@ var_dump(gmp_strval(gmp_or($n, $n1)));
 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(6) "517363"
 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 16fca508bff3..b9b31050e71a 100644
--- a/ext/gmp/tests/gmp_perfect_square.phpt
+++ b/ext/gmp/tests/gmp_perfect_square.phpt
@@ -24,7 +24,7 @@ var_dump(gmp_perfect_square($n));
 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(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 3b61eec5b7aa..3b15a659c5ed 100644
--- a/ext/gmp/tests/gmp_popcount.phpt
+++ b/ext/gmp/tests/gmp_popcount.phpt
@@ -16,7 +16,7 @@ var_dump(gmp_popcount($n));
 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(10)
 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 36d0d16d8ccc..ae206e3a7fcf 100644
--- a/ext/gmp/tests/gmp_pow.phpt
+++ b/ext/gmp/tests/gmp_pow.phpt
@@ -13,7 +13,7 @@ var_dump(gmp_strval(gmp_pow("2",0)));
 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 @@ var_dump(gmp_strval(gmp_pow(50,10)));
 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 @@ var_dump(gmp_strval(gmp_pow($n,10)));
 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(4) "1024"
 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 96f33e8c25ca..5902e00a3d2a 100644
--- a/ext/gmp/tests/gmp_pow2.phpt
+++ b/ext/gmp/tests/gmp_pow2.phpt
@@ -12,13 +12,13 @@ var_dump($n ** 10);
 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 @@ object(GMP)#%d (1) {
   ["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 2c66ff25a5e5..1ec9bbb03198 100644
--- a/ext/gmp/tests/gmp_powm_sec.phpt
+++ b/ext/gmp/tests/gmp_powm_sec.phpt
@@ -18,20 +18,20 @@ foreach ([0, -1] as $exp) {
     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 79709f272715..92d20fd5ed7d 100644
--- a/ext/gmp/tests/gmp_pown.phpt
+++ b/ext/gmp/tests/gmp_pown.phpt
@@ -22,40 +22,40 @@ var_dump(gmp_strval(gmp_powm($n,$e,$m)));
 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) "533"
 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 541a62f918d5..117d7573d83b 100644
--- a/ext/gmp/tests/gmp_prevprime.phpt
+++ b/ext/gmp/tests/gmp_prevprime.phpt
@@ -15,7 +15,7 @@ foreach ([-1, 0, 1, 2] as $value) {
     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 @@ $definitelyPrime = null;
 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 @@ var_dump($definitelyPrime === (gmp_prob_prime($previousPrime) === 2));
 
 ?>
 --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 7c93a48bd935..9a962613b4dd 100644
--- a/ext/gmp/tests/gmp_prob_prime.phpt
+++ b/ext/gmp/tests/gmp_prob_prime.phpt
@@ -31,7 +31,7 @@ var_dump(gmp_prob_prime($n));
 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)
 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 4e7f33798389..55693814fed4 100644
--- a/ext/gmp/tests/gmp_random_bits.phpt
+++ b/ext/gmp/tests/gmp_random_bits.phpt
@@ -8,12 +8,12 @@ gmp
 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 @@ while (1) {
 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 59ac5762fce0..9882bf4ffa3b 100644
--- a/ext/gmp/tests/gmp_random_range.phpt
+++ b/ext/gmp/tests/gmp_random_range.phpt
@@ -12,18 +12,18 @@ $zero = gmp_init(0);
 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 @@ while (1) {
 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 bfb45739f54d..71b25dbf3729 100644
--- a/ext/gmp/tests/gmp_random_seed.phpt
+++ b/ext/gmp/tests/gmp_random_seed.phpt
@@ -110,7 +110,7 @@ var_dump(gmp_strval(gmp_random_range(-10000, 0)));
 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(301) "7240560133683902061389868703829443708354917824328579773726122219756
 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 fe7a8316e596..8bf0a1b4a7f3 100644
--- a/ext/gmp/tests/gmp_remroot.phpt
+++ b/ext/gmp/tests/gmp_remroot.phpt
@@ -14,7 +14,7 @@ var_dump(gmp_rootrem(100, 4));
 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 @@ var_dump(gmp_rootrem(0, 3));
 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 @@ array(2) {
     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 @@ array(2) {
     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 b4a88405a211..3134d5b8e6ac 100644
--- a/ext/gmp/tests/gmp_root.phpt
+++ b/ext/gmp/tests/gmp_root.phpt
@@ -15,7 +15,7 @@ var_dump(gmp_root(100, 4));
 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 @@ var_dump(gmp_root(0, 3));
 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 @@ object(GMP)#%d (1) {
   ["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 3accf37eee10..982f2b67410c 100644
--- a/ext/gmp/tests/gmp_scan0.phpt
+++ b/ext/gmp/tests/gmp_scan0.phpt
@@ -8,7 +8,7 @@ gmp
 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 @@ var_dump(gmp_scan0($n, 10));
 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 8021f7e679d8..83a70bcba263 100644
--- a/ext/gmp/tests/gmp_scan1.phpt
+++ b/ext/gmp/tests/gmp_scan1.phpt
@@ -8,7 +8,7 @@ gmp
 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 @@ var_dump(gmp_scan1($n, 10));
 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 775042ef9737..09ce16ada7fe 100644
--- a/ext/gmp/tests/gmp_setbit.phpt
+++ b/ext/gmp/tests/gmp_setbit.phpt
@@ -13,7 +13,7 @@ $n = gmp_init(5);
 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 @@ $b = "";
 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 bbd472de967e..e6d2dc262d59 100644
--- a/ext/gmp/tests/gmp_setbit_long.phpt
+++ b/ext/gmp/tests/gmp_setbit_long.phpt
@@ -30,7 +30,7 @@ for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) {
     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 @@ FFFFFFFF
 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 56706b20eda1..7b1dba970fdc 100644
--- a/ext/gmp/tests/gmp_sign.phpt
+++ b/ext/gmp/tests/gmp_sign.phpt
@@ -14,18 +14,18 @@ var_dump(gmp_sign("-34535345345"));
 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(1)
 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 50da298161ce..52a13a3d3ffb 100644
--- a/ext/gmp/tests/gmp_sqrt.phpt
+++ b/ext/gmp/tests/gmp_sqrt.phpt
@@ -8,12 +8,12 @@ gmp
 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 @@ $n = gmp_init(-144);
 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 @@ var_dump(gmp_strval(gmp_sqrt($n)));
 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 915fc4ed2f9e..a9602b64089d 100644
--- a/ext/gmp/tests/gmp_sqrtrem.phpt
+++ b/ext/gmp/tests/gmp_sqrtrem.phpt
@@ -9,7 +9,7 @@ try {
     $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 @@ try {
     $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 @@ var_dump(gmp_strval($r[1]));
 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(4) "1000"
 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 006f06465c53..3e11b0d095ee 100644
--- a/ext/gmp/tests/gmp_strict_types.phpt
+++ b/ext/gmp/tests/gmp_strict_types.phpt
@@ -13,27 +13,27 @@ var_dump(gmp_abs("-1"));
 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 @@ object(GMP)#2 (1) {
   ["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 1221d04b3b1d..771c0e203012 100644
--- a/ext/gmp/tests/gmp_strval.phpt
+++ b/ext/gmp/tests/gmp_strval.phpt
@@ -8,19 +8,19 @@ gmp
 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 @@ var_dump(gmp_strval($g));
 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 @@ var_dump(gmp_strval($g));
 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 5161bce10356..9cbf2097cc35 100644
--- a/ext/gmp/tests/gmp_sub.phpt
+++ b/ext/gmp/tests/gmp_sub.phpt
@@ -8,12 +8,12 @@ gmp
 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 @@ try {
     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 @@ object(GMP)#3 (1) {
   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 1cef8cd4166b..fb6497df5463 100644
--- a/ext/gmp/tests/gmp_testbit.phpt
+++ b/ext/gmp/tests/gmp_testbit.phpt
@@ -10,7 +10,7 @@ $n = gmp_init(0);
 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 @@ var_dump(gmp_testbit($n, 1));
 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 @@ var_dump(gmp_strval($n));
 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 fdc8a67562cf..a60500147ca1 100644
--- a/ext/gmp/tests/gmp_xor.phpt
+++ b/ext/gmp/tests/gmp_xor.phpt
@@ -14,7 +14,7 @@ var_dump(gmp_strval(gmp_xor(4545, -20)));
 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 @@ var_dump(gmp_strval(gmp_xor($n, $n1)));
 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(6) "476369"
 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 f55a83f0bd5f..7d078784e2fa 100644
--- a/ext/gmp/tests/overloading.phpt
+++ b/ext/gmp/tests/overloading.phpt
@@ -26,7 +26,7 @@ var_dump(42 / $b);
 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 @@ var_dump(42 % $b);
 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 @@ var_dump(-$a >> 2);
 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 @@ var_dump($a >= 42);
 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 @@ object(GMP)#3 (1) {
   ["num"]=>
   string(1) "2"
 }
-Division by zero
+DivisionByZeroError: Division by zero
 object(GMP)#4 (1) {
   ["num"]=>
   string(1) "8"
@@ -185,7 +185,7 @@ object(GMP)#4 (1) {
   ["num"]=>
   string(1) "8"
 }
-Modulo by zero
+DivisionByZeroError: Modulo by zero
 object(GMP)#3 (1) {
   ["num"]=>
   string(28) "3937657486715347520027492352"
@@ -254,8 +254,8 @@ object(GMP)#5 (1) {
   ["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(false)
 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 84877459a9bc..3926a1eb284a 100644
--- a/ext/gmp/tests/serialize.phpt
+++ b/ext/gmp/tests/serialize.phpt
@@ -18,27 +18,27 @@ var_dump(unserialize('C:3:"GMP":15:{s:2:"42";a:0:{}}'));
 
 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 @@ object(GMP)#1 (1) {
   ["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 a4578f7afb55..dd5a2540d07b 100644
--- a/ext/gmp/tests/surprising_integer_literals.phpt
+++ b/ext/gmp/tests/surprising_integer_literals.phpt
@@ -19,15 +19,15 @@ foreach ($values as $value) {
     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