[php-src] master: ext/curl: applied fixers to improve test robustness (#23038)

NickSdot via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-08-12T19:17:12+08:00

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

ext/curl: applied fixers to improve test robustness (#23038)

Changed paths:
  M  ext/curl/tests/bug48207.phpt
  M  ext/curl/tests/bug68089.phpt
  M  ext/curl/tests/bug73147.phpt
  M  ext/curl/tests/bug80121.phpt
  M  ext/curl/tests/curl_file_upload.phpt
  M  ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt
  M  ext/curl/tests/curl_multi_errno_strerror_001.phpt
  M  ext/curl/tests/curl_multi_setopt_basic001.phpt
  M  ext/curl/tests/curl_persistent_share_003.phpt
  M  ext/curl/tests/curl_persistent_share_004.phpt
  M  ext/curl/tests/curl_persistent_share_005.phpt
  M  ext/curl/tests/curl_persistent_share_006.phpt
  M  ext/curl/tests/curl_seekfunction_error.phpt
  M  ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt
  M  ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
  M  ext/curl/tests/curl_setopt_basic003.phpt
  M  ext/curl/tests/curl_setopt_error.phpt
  M  ext/curl/tests/curl_setopt_error_nul_byte.phpt
  M  ext/curl/tests/curl_share_errno_strerror_001.phpt
  M  ext/curl/tests/curl_share_setopt_basic001.phpt
  M  ext/curl/tests/gh15547.phpt


Diff:

diff --git a/ext/curl/tests/bug48207.phpt b/ext/curl/tests/bug48207.phpt
index 6487076e9ee3..68b945f4bf8c 100644
--- a/ext/curl/tests/bug48207.phpt
+++ b/ext/curl/tests/bug48207.phpt
@@ -45,7 +45,7 @@ foreach ([
     try {
         curl_setopt($ch, $option, $fp);
     } catch (ValueError $exception) {
-        echo $exception->getMessage(), "\n";
+        echo $exception::class, ': ', $exception->getMessage(), "\n";
     }
 }
 
@@ -54,8 +54,8 @@ is_file($tempfile) and @unlink($tempfile);
 isset($tempname) and is_file($tempname) and @unlink($tempname);
 ?>
 --EXPECT--
-curl_setopt(): The file handle provided for CURLOPT_FILE must be writable
-curl_setopt(): The file handle provided for CURLOPT_WRITEHEADER must be writable
-curl_setopt(): The file handle provided for CURLOPT_STDERR must be writable
+ValueError: curl_setopt(): The file handle provided for CURLOPT_FILE must be writable
+ValueError: curl_setopt(): The file handle provided for CURLOPT_WRITEHEADER must be writable
+ValueError: curl_setopt(): The file handle provided for CURLOPT_STDERR must be writable
 Hello World!
 Hello World!
diff --git a/ext/curl/tests/bug68089.phpt b/ext/curl/tests/bug68089.phpt
index c175df5248fe..6a909c39f770 100644
--- a/ext/curl/tests/bug68089.phpt
+++ b/ext/curl/tests/bug68089.phpt
@@ -10,11 +10,11 @@ $ch = curl_init();
 try {
     curl_setopt($ch, CURLOPT_URL, $url);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 ?>
 Done
 --EXPECT--
-curl_setopt(): cURL option CURLOPT_URL must not contain any null bytes
+ValueError: curl_setopt(): cURL option CURLOPT_URL must not contain any null bytes
 Done
diff --git a/ext/curl/tests/bug73147.phpt b/ext/curl/tests/bug73147.phpt
index b0f01e64e31d..4561785cb999 100644
--- a/ext/curl/tests/bug73147.phpt
+++ b/ext/curl/tests/bug73147.phpt
@@ -8,8 +8,8 @@ $poc = 'a:1:{i:0;O:8:"CURLFile":1:{s:4:"name";R:1;}}';
 try {
     var_dump(unserialize($poc));
 } catch(Exception $e) {
-    echo $e->getMessage();
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 ?>
 --EXPECT--
-Unserialization of 'CURLFile' is not allowed
+Exception: Unserialization of 'CURLFile' is not allowed
diff --git a/ext/curl/tests/bug80121.phpt b/ext/curl/tests/bug80121.phpt
index a7bf6385367d..d750856f06ec 100644
--- a/ext/curl/tests/bug80121.phpt
+++ b/ext/curl/tests/bug80121.phpt
@@ -8,21 +8,21 @@ curl
 try {
     new CurlHandle;
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     new CurlMultiHandle;
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 try {
     new CurlShareHandle;
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-Cannot directly construct CurlHandle, use curl_init() instead
-Cannot directly construct CurlMultiHandle, use curl_multi_init() instead
-Cannot directly construct CurlShareHandle, use curl_share_init() instead
+Error: Cannot directly construct CurlHandle, use curl_init() instead
+Error: Cannot directly construct CurlMultiHandle, use curl_multi_init() instead
+Error: Cannot directly construct CurlShareHandle, use curl_share_init() instead
diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt
index 8b85190ff41e..732d626c664b 100644
--- a/ext/curl/tests/curl_file_upload.phpt
+++ b/ext/curl/tests/curl_file_upload.phpt
@@ -45,7 +45,7 @@ var_dump(curl_exec($ch));
 try {
     curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt');
@@ -72,7 +72,7 @@ string(%d) "%s/curl_testdata1.txt"
 string(%d) "curl_testdata1.txt|text/plain|6"
 string(%d) "foo.txt"
 string(%d) "foo.txt|application/octet-stream|6"
-curl_setopt(): Disabling safe uploads is no longer supported
+ValueError: curl_setopt(): Disabling safe uploads is no longer supported
 string(0) ""
 string(0) ""
 string(%d) "array(1) {
diff --git a/ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt b/ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt
index 4a90b0a3c52e..be671e73ef3c 100644
--- a/ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt
+++ b/ext/curl/tests/curl_getinfo_CURLINFO_CONN_ID.phpt
@@ -143,4 +143,3 @@ bool(true)
 bool(true)
 bool(true)
 bool(true)
-
diff --git a/ext/curl/tests/curl_multi_errno_strerror_001.phpt b/ext/curl/tests/curl_multi_errno_strerror_001.phpt
index 80ec44c4c247..9bb9b168f828 100644
--- a/ext/curl/tests/curl_multi_errno_strerror_001.phpt
+++ b/ext/curl/tests/curl_multi_errno_strerror_001.phpt
@@ -13,7 +13,7 @@ echo curl_multi_strerror($errno) . PHP_EOL;
 try {
     curl_multi_setopt($mh, -1, -1);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $errno = curl_multi_errno($mh);
@@ -23,6 +23,6 @@ echo curl_multi_strerror($errno) . PHP_EOL;
 --EXPECT--
 0
 No error
-curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
+ValueError: curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
 6
 Unknown option
diff --git a/ext/curl/tests/curl_multi_setopt_basic001.phpt b/ext/curl/tests/curl_multi_setopt_basic001.phpt
index 71d176c0a109..479ae758e0c2 100644
--- a/ext/curl/tests/curl_multi_setopt_basic001.phpt
+++ b/ext/curl/tests/curl_multi_setopt_basic001.phpt
@@ -11,10 +11,10 @@ var_dump(curl_multi_setopt($mh, CURLMOPT_PIPELINING, 0));
 try {
     curl_multi_setopt($mh, -1, 0);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
 bool(true)
-curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
+ValueError: curl_multi_setopt(): Argument #2 ($option) is not a valid cURL multi option
diff --git a/ext/curl/tests/curl_persistent_share_003.phpt b/ext/curl/tests/curl_persistent_share_003.phpt
index 60a30de4d464..0ed7dfd22e97 100644
--- a/ext/curl/tests/curl_persistent_share_003.phpt
+++ b/ext/curl/tests/curl_persistent_share_003.phpt
@@ -8,9 +8,9 @@ curl
 try {
     $sh = curl_share_init_persistent([CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_CONNECT, 30]);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 ?>
 --EXPECT--
-curl_share_init_persistent(): Argument #1 ($share_options) must contain only CURL_LOCK_DATA_* constants
+ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must contain only CURL_LOCK_DATA_* constants
diff --git a/ext/curl/tests/curl_persistent_share_004.phpt b/ext/curl/tests/curl_persistent_share_004.phpt
index fe0e7ec2cf0e..ffd58abc0172 100644
--- a/ext/curl/tests/curl_persistent_share_004.phpt
+++ b/ext/curl/tests/curl_persistent_share_004.phpt
@@ -8,9 +8,9 @@ curl
 try {
     $sh = curl_share_init_persistent([CURL_LOCK_DATA_COOKIE]);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 ?>
 --EXPECT--
-curl_share_init_persistent(): Argument #1 ($share_options) must not contain CURL_LOCK_DATA_COOKIE because sharing cookies across PHP requests is unsafe
+ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must not contain CURL_LOCK_DATA_COOKIE because sharing cookies across PHP requests is unsafe
diff --git a/ext/curl/tests/curl_persistent_share_005.phpt b/ext/curl/tests/curl_persistent_share_005.phpt
index 8737ba6c39a4..7b7403a76f3b 100644
--- a/ext/curl/tests/curl_persistent_share_005.phpt
+++ b/ext/curl/tests/curl_persistent_share_005.phpt
@@ -10,9 +10,9 @@ $sh = curl_share_init_persistent([CURL_LOCK_DATA_DNS]);
 try {
     curl_share_setopt($sh, CURLOPT_SHARE, CURL_LOCK_DATA_CONNECT);
 } catch (\TypeError $e) {
-    echo $e->getMessage() . PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 ?>
 --EXPECT--
-curl_share_setopt(): Argument #1 ($share_handle) must be of type CurlShareHandle, CurlSharePersistentHandle given
+TypeError: curl_share_setopt(): Argument #1 ($share_handle) must be of type CurlShareHandle, CurlSharePersistentHandle given
diff --git a/ext/curl/tests/curl_persistent_share_006.phpt b/ext/curl/tests/curl_persistent_share_006.phpt
index ffca764757fb..8921ddba8903 100644
--- a/ext/curl/tests/curl_persistent_share_006.phpt
+++ b/ext/curl/tests/curl_persistent_share_006.phpt
@@ -8,9 +8,9 @@ curl
 try {
     $sh = curl_share_init_persistent([]);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 ?>
 --EXPECT--
-curl_share_init_persistent(): Argument #1 ($share_options) must not be empty
+ValueError: curl_share_init_persistent(): Argument #1 ($share_options) must not be empty
diff --git a/ext/curl/tests/curl_seekfunction_error.phpt b/ext/curl/tests/curl_seekfunction_error.phpt
index 134e8115dc5f..31808d78a3c8 100644
--- a/ext/curl/tests/curl_seekfunction_error.phpt
+++ b/ext/curl/tests/curl_seekfunction_error.phpt
@@ -31,14 +31,14 @@ echo "Returning a non-int:\n";
 try {
     run_upload($host, fn($ch, $offset, $origin) => 'not an int');
 } catch (\TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 echo "\nReturning an out-of-range int:\n";
 try {
     run_upload($host, fn($ch, $offset, $origin) => 42);
 } catch (\ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 echo "\nThrowing from the callback:\n";
@@ -47,7 +47,7 @@ try {
         throw new \RuntimeException('boom from seek');
     });
 } catch (\RuntimeException $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 echo "\nSetting the callback to null:\n";
@@ -57,21 +57,21 @@ echo "\nSetting a non-callable scalar:\n";
 try {
     curl_setopt(curl_init(), CURLOPT_SEEKFUNCTION, 42);
 } catch (\TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
 Returning a non-int:
-The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
+TypeError: The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
 
 Returning an out-of-range int:
-The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
+ValueError: The CURLOPT_SEEKFUNCTION callback must return one of CURL_SEEKFUNC_OK, CURL_SEEKFUNC_FAIL or CURL_SEEKFUNC_CANTSEEK
 
 Throwing from the callback:
-boom from seek
+RuntimeException: boom from seek
 
 Setting the callback to null:
 bool(true)
 
 Setting a non-callable scalar:
-curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SEEKFUNCTION, no array or string given
+TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SEEKFUNCTION, no array or string given
diff --git a/ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt b/ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt
index 7193642dcab0..b523acc1648b 100644
--- a/ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt
+++ b/ext/curl/tests/curl_setopt_CURLOPT_DEBUGFUNCTION.phpt
@@ -87,14 +87,14 @@ try {
     var_dump(curl_setopt($ch, CURLINFO_HEADER_OUT, true));
 }
 catch (\ValueError $e) {
-    var_dump($e->getMessage());
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 $chCopy = curl_copy_handle($ch);
 try {
     var_dump(curl_setopt($chCopy, CURLINFO_HEADER_OUT, true));
 }
 catch (\ValueError $e) {
-    var_dump($e->getMessage());
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 var_dump(curl_setopt($chCopy, CURLOPT_DEBUGFUNCTION, null));
 var_dump(curl_setopt($chCopy, CURLINFO_HEADER_OUT, true));
@@ -138,7 +138,7 @@ try {
     var_dump($result = curl_exec($ch));
 }
 catch (\RuntimeException $e) {
-    var_dump($e->getMessage());
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 var_dump(curl_getinfo($ch, CURLINFO_HEADER_OUT));
 
@@ -183,8 +183,8 @@ bool(true)
 bool(true)
 bool(true)
 bool(true)
-string(87) "CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set"
-string(87) "CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set"
+ValueError: CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set
+ValueError: CURLINFO_HEADER_OUT option must not be set when the CURLOPT_DEBUGFUNCTION option is set
 bool(true)
 bool(true)
 
@@ -216,7 +216,7 @@ Accept: */*
 
 ===Test CURLOPT_DEBUGFUNCTION can throw within callback===
 bool(true)
-string(41) "This should get caught after verbose=true"
+RuntimeException: This should get caught after verbose=true
 string(%d) "GET /get.inc?test=file HTTP/%s
 Host: %s:%d
 Accept: */*
diff --git a/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt b/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
index 39a1d1e3caa8..8f507a6c8fd9 100644
--- a/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
+++ b/ext/curl/tests/curl_setopt_CURLOPT_PREREQFUNCTION.phpt
@@ -73,7 +73,7 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
 try {
     curl_exec($ch);
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 echo "\nTesting with invalid type\n";
@@ -83,7 +83,7 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
 try {
     curl_exec($ch);
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 echo "\nTesting with invalid value\n";
@@ -93,21 +93,21 @@ curl_setopt($ch, CURLOPT_PREREQFUNCTION, function() use ($port) {
 try {
     curl_exec($ch);
 } catch (\ValueError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 echo "\nTesting with invalid option value\n";
 try {
     curl_setopt($ch, CURLOPT_PREREQFUNCTION, 42);
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 echo "\nTesting with invalid option callback\n";
 try {
     curl_setopt($ch, CURLOPT_PREREQFUNCTION, 'function_does_not_exist');
 } catch (\TypeError $e) {
-    echo $e->getMessage() . \PHP_EOL;
+    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 
 echo "\nTesting with null as the callback\n";
@@ -161,19 +161,19 @@ string(0) ""
 int(0)
 
 Testing with no return type
-The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
+TypeError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
 
 Testing with invalid type
-The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
+TypeError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
 
 Testing with invalid value
-The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
+ValueError: The CURLOPT_PREREQFUNCTION callback must return either CURL_PREREQFUNC_OK or CURL_PREREQFUNC_ABORT
 
 Testing with invalid option value
-curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, no array or string given
+TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, no array or string given
 
 Testing with invalid option callback
-curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, function "function_does_not_exist" not found or invalid function name
+TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PREREQFUNCTION, function "function_does_not_exist" not found or invalid function name
 
 Testing with null as the callback
 bool(true)
diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt
index 008162c9b474..daeac6b07c14 100644
--- a/ext/curl/tests/curl_setopt_basic003.phpt
+++ b/ext/curl/tests/curl_setopt_basic003.phpt
@@ -20,7 +20,7 @@ $ch = curl_init();
 try {
     curl_setopt($ch, CURLOPT_HTTPHEADER, 1);
 } catch (TypeError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 $curl_content = curl_exec($ch);
@@ -42,6 +42,6 @@ var_dump( $curl_content );
 ?>
 --EXPECT--
 *** curl_setopt() call with CURLOPT_HTTPHEADER
-curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value
+TypeError: curl_setopt(): The CURLOPT_HTTPHEADER option must have an array value
 bool(false)
 bool(true)
diff --git a/ext/curl/tests/curl_setopt_error.phpt b/ext/curl/tests/curl_setopt_error.phpt
index 0979cec0816d..0495d2e56dab 100644
--- a/ext/curl/tests/curl_setopt_error.phpt
+++ b/ext/curl/tests/curl_setopt_error.phpt
@@ -13,24 +13,24 @@ $ch = curl_init();
 try {
     curl_setopt($ch, '', false);
 } catch (TypeError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     curl_setopt($ch, -10, 0);
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     curl_setopt($ch, 1000, 0);
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
 *** curl_setopt() call with incorrect parameters
-curl_setopt(): Argument #2 ($option) must be of type int, string given
-curl_setopt(): Argument #2 ($option) is not a valid cURL option
-curl_setopt(): Argument #2 ($option) is not a valid cURL option
+TypeError: curl_setopt(): Argument #2 ($option) must be of type int, string given
+ValueError: curl_setopt(): Argument #2 ($option) is not a valid cURL option
+ValueError: curl_setopt(): Argument #2 ($option) is not a valid cURL option
diff --git a/ext/curl/tests/curl_setopt_error_nul_byte.phpt b/ext/curl/tests/curl_setopt_error_nul_byte.phpt
index 23be973b82c2..8eae484b51d9 100644
--- a/ext/curl/tests/curl_setopt_error_nul_byte.phpt
+++ b/ext/curl/tests/curl_setopt_error_nul_byte.phpt
@@ -24,29 +24,20 @@ foreach ($list_options as $option) {
     try {
         curl_setopt($ch, constant($option), ["Something: foo\0bar"]);
     } catch (ValueError $exception) {
-        echo $option . ": " . $exception->getMessage() . "\n\n";
+        echo $option, ': ', $exception::class, ': ', $exception->getMessage(), "\n";
     }
 }
 
 $ch = null;
 ?>
 --EXPECT--
-CURLOPT_HTTP200ALIASES: curl_setopt(): cURL option CURLOPT_HTTP200ALIASES must not contain any null bytes
-
-CURLOPT_HTTPHEADER: curl_setopt(): cURL option CURLOPT_HTTPHEADER must not contain any null bytes
-
-CURLOPT_POSTQUOTE: curl_setopt(): cURL option CURLOPT_POSTQUOTE must not contain any null bytes
-
-CURLOPT_PREQUOTE: curl_setopt(): cURL option CURLOPT_PREQUOTE must not contain any null bytes
-
-CURLOPT_QUOTE: curl_setopt(): cURL option CURLOPT_QUOTE must not contain any null bytes
-
-CURLOPT_TELNETOPTIONS: curl_setopt(): cURL option CURLOPT_TELNETOPTIONS must not contain any null bytes
-
-CURLOPT_MAIL_RCPT: curl_setopt(): cURL option CURLOPT_MAIL_RCPT must not contain any null bytes
-
-CURLOPT_RESOLVE: curl_setopt(): cURL option CURLOPT_RESOLVE must not contain any null bytes
-
-CURLOPT_PROXYHEADER: curl_setopt(): cURL option CURLOPT_PROXYHEADER must not contain any null bytes
-
-CURLOPT_CONNECT_TO: curl_setopt(): cURL option CURLOPT_CONNECT_TO must not contain any null bytes
+CURLOPT_HTTP200ALIASES: ValueError: curl_setopt(): cURL option CURLOPT_HTTP200ALIASES must not contain any null bytes
+CURLOPT_HTTPHEADER: ValueError: curl_setopt(): cURL option CURLOPT_HTTPHEADER must not contain any null bytes
+CURLOPT_POSTQUOTE: ValueError: curl_setopt(): cURL option CURLOPT_POSTQUOTE must not contain any null bytes
+CURLOPT_PREQUOTE: ValueError: curl_setopt(): cURL option CURLOPT_PREQUOTE must not contain any null bytes
+CURLOPT_QUOTE: ValueError: curl_setopt(): cURL option CURLOPT_QUOTE must not contain any null bytes
+CURLOPT_TELNETOPTIONS: ValueError: curl_setopt(): cURL option CURLOPT_TELNETOPTIONS must not contain any null bytes
+CURLOPT_MAIL_RCPT: ValueError: curl_setopt(): cURL option CURLOPT_MAIL_RCPT must not contain any null bytes
+CURLOPT_RESOLVE: ValueError: curl_setopt(): cURL option CURLOPT_RESOLVE must not contain any null bytes
+CURLOPT_PROXYHEADER: ValueError: curl_setopt(): cURL option CURLOPT_PROXYHEADER must not contain any null bytes
+CURLOPT_CONNECT_TO: ValueError: curl_setopt(): cURL option CURLOPT_CONNECT_TO must not contain any null bytes
diff --git a/ext/curl/tests/curl_share_errno_strerror_001.phpt b/ext/curl/tests/curl_share_errno_strerror_001.phpt
index 6a69a3a48773..835b8a8afef2 100644
--- a/ext/curl/tests/curl_share_errno_strerror_001.phpt
+++ b/ext/curl/tests/curl_share_errno_strerror_001.phpt
@@ -13,7 +13,7 @@ echo curl_share_strerror($errno) . PHP_EOL;
 try {
     curl_share_setopt($sh, -1, -1);
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 $errno = curl_share_errno($sh);
@@ -23,6 +23,6 @@ echo curl_share_strerror($errno) . PHP_EOL;
 --EXPECT--
 0
 No error
-curl_share_setopt(): Argument #2 ($option) is not a valid cURL share option
+ValueError: curl_share_setopt(): Argument #2 ($option) is not a valid cURL share option
 1
 Unknown share option
diff --git a/ext/curl/tests/curl_share_setopt_basic001.phpt b/ext/curl/tests/curl_share_setopt_basic001.phpt
index d9a9c1788e88..11a5e4d1dc87 100644
--- a/ext/curl/tests/curl_share_setopt_basic001.phpt
+++ b/ext/curl/tests/curl_share_setopt_basic001.phpt
@@ -12,11 +12,11 @@ var_dump(curl_share_setopt($sh, CURLSHOPT_UNSHARE, CURL_LOCK_DATA_DNS));
 try {
     curl_share_setopt($sh, -1, 0);
 } catch (ValueError $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
 bool(true)
 bool(true)
-curl_share_setopt(): Argument #2 ($option) is not a valid cURL share option
+ValueError: curl_share_setopt(): Argument #2 ($option) is not a valid cURL share option
diff --git a/ext/curl/tests/gh15547.phpt b/ext/curl/tests/gh15547.phpt
index 489fdd0b999a..6b2b0521a1c6 100644
--- a/ext/curl/tests/gh15547.phpt
+++ b/ext/curl/tests/gh15547.phpt
@@ -10,20 +10,20 @@ $mh = curl_multi_init();
 try {
 	curl_multi_select($mh, -2500000);
 } catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 curl_multi_close($mh);
 $mh = curl_multi_init();
 try {
 	curl_multi_select($mh, 2500000);
 } catch (\ValueError $e) {
-	echo $e->getMessage() . PHP_EOL;
+	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
 }
 curl_multi_close($mh);
 $mh = curl_multi_init();
 var_dump(curl_multi_select($mh, 1000000));
 ?>
 --EXPECTF--
-curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
-curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
+ValueError: curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
+ValueError: curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
 int(0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.