[php-src] master: ext/date: applied fixers to improve test robustness

NickSdot via Derick Rethans <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: Derick Rethans (derickr)
Date: 2026-08-18T18:03:00+01:00

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

ext/date: applied fixers to improve test robustness

Changed paths:
  M  ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
  M  ext/date/tests/DatePeriod_wrong_constructor.phpt
  M  ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt
  M  ext/date/tests/bug-gh11416.phpt
  M  ext/date/tests/bug-gh15582.phpt
  M  ext/date/tests/bug-gh8471.phpt
  M  ext/date/tests/bug51819.phpt
  M  ext/date/tests/bug54283.phpt
  M  ext/date/tests/bug62500.phpt
  M  ext/date/tests/bug71826.phpt
  M  ext/date/tests/bug72963.phpt
  M  ext/date/tests/bug77097.phpt
  M  ext/date/tests/bug78139.phpt
  M  ext/date/tests/createFromTimestamp.phpt
  M  ext/date/tests/date_interval_set_state_error1.phpt
  M  ext/date/tests/date_period_exclude_start_and_include_end.phpt
  M  ext/date/tests/date_period_unset_property.phpt
  M  ext/date/tests/date_sunrise_and_sunset_error.phpt
  M  ext/date/tests/getSetMicroseconds.phpt
  M  ext/date/tests/gh14732.phpt
  M  ext/date/tests/gh20936.phpt
  M  ext/date/tests/instantiate_uninstantiable_classes.phpt
  M  ext/date/tests/timezone_offset_get_error.phpt
  M  ext/date/tests/unserialize-test.phpt


Diff:

diff --git a/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt b/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
index f8b1e1cffe43..a5ae7e11b29f 100644
--- a/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
+++ b/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
@@ -10,13 +10,13 @@ var_dump(MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:00:00Z/P7D"));
 try {
     MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:/P7D");
 } catch (DateMalformedPeriodStringException $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDatePeriod::createFromISO8601String("R4/2012-07-01T00:00:00Z");
 } catch (DateMalformedPeriodStringException $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
@@ -65,5 +65,5 @@ object(MyDatePeriod)#1 (7) {
   ["include_end_date"]=>
   bool(false)
 }
-Unknown or bad format (R4/2012-07-01T00:/P7D)
-DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
+DateMalformedPeriodStringException: Unknown or bad format (R4/2012-07-01T00:/P7D)
+DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
diff --git a/ext/date/tests/DatePeriod_wrong_constructor.phpt b/ext/date/tests/DatePeriod_wrong_constructor.phpt
index 45f99bdb7270..eaf326f842ef 100644
--- a/ext/date/tests/DatePeriod_wrong_constructor.phpt
+++ b/ext/date/tests/DatePeriod_wrong_constructor.phpt
@@ -11,8 +11,8 @@ date.timezone=UTC
 try {
     new DatePeriod();
 } catch (TypeError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 ?>
 --EXPECT--
-DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments
+TypeError: DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments
diff --git a/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt b/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt
index 31c6868d67fb..8e7a57fefe03 100644
--- a/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt
+++ b/ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt
@@ -5,16 +5,16 @@ DatePeriod: Test wrong recurrence parameter on __construct
 try {
     new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), 0);
 } catch (Exception $exception) {
-    echo $exception->getMessage(), "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 try {
     new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), -1);
 } catch (Exception $exception) {
-    echo $exception->getMessage(), "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 ?>
 --EXPECTF--
-DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
-DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
+DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
+DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
diff --git a/ext/date/tests/bug-gh11416.phpt b/ext/date/tests/bug-gh11416.phpt
index 546867924cb4..ab8452d5897f 100644
--- a/ext/date/tests/bug-gh11416.phpt
+++ b/ext/date/tests/bug-gh11416.phpt
@@ -11,14 +11,14 @@ $date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
 try {
 	new DatePeriod($date, new DateInterval('P1D'), 2);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 $date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
 try {
 	new DatePeriod($now, new DateInterval('P1D'), $date);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 $date = (new ReflectionClass(DateTime::class))->newInstanceWithoutConstructor();
@@ -27,25 +27,25 @@ $dateinterval = (new ReflectionClass(DateInterval::class))->newInstanceWithoutCo
 try {
 	$dateperiod->__unserialize(['start' => $date]);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
 	$dateperiod->__unserialize(['start' => $now, 'end' => $date]);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
 	$dateperiod->__unserialize(['start' => $now, 'end' => $now, 'current' => $date]);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
 	$dateperiod->__unserialize(['start' => $now, 'end' => $now, 'current' => $now, 'interval' => $dateinterval]);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
@@ -55,7 +55,7 @@ try {
 	]);
 	echo "DatePeriod::__unserialize: SUCCESS\n";
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 echo "OK\n";
 ?>
diff --git a/ext/date/tests/bug-gh15582.phpt b/ext/date/tests/bug-gh15582.phpt
index ab03e190e4bc..2dd6ec59b8f2 100644
--- a/ext/date/tests/bug-gh15582.phpt
+++ b/ext/date/tests/bug-gh15582.phpt
@@ -14,7 +14,7 @@ $fusion = $mdtz;
 try {
 	date_create("2005-07-14 22:30:41", $fusion);
 } catch (Error $e) {
-	echo get_class($e), ': ', $e->getMessage(), "\n";
+	echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
diff --git a/ext/date/tests/bug-gh8471.phpt b/ext/date/tests/bug-gh8471.phpt
index 2f6656849f6c..0c1c69418692 100644
--- a/ext/date/tests/bug-gh8471.phpt
+++ b/ext/date/tests/bug-gh8471.phpt
@@ -8,7 +8,7 @@ $mutable = $reflection->newInstanceWithoutConstructor();
 try {
 	$immutable = \DateTimeImmutable::createFromMutable($mutable);
 } catch (Throwable $t) {
-	echo $t->getMessage(), "\n";
+	echo $t::class, ': ', $t->getMessage(), "\n";
 }
 
 
@@ -18,7 +18,7 @@ $mutable = $reflection->newInstanceWithoutConstructor();
 try {
 	$immutable = \DateTimeImmutable::createFromInterface($mutable);
 } catch (Throwable $t) {
-	echo $t->getMessage(), "\n";
+	echo $t::class, ': ', $t->getMessage(), "\n";
 }
 
 
@@ -28,7 +28,7 @@ $immutable = $reflection->newInstanceWithoutConstructor();
 try {
 	$mutable = \DateTime::createFromImmutable($immutable);
 } catch (Throwable $t) {
-	echo $t->getMessage(), "\n";
+	echo $t::class, ': ', $t->getMessage(), "\n";
 }
 
 
@@ -38,13 +38,13 @@ $immutable = $reflection->newInstanceWithoutConstructor();
 try {
 	$mutable = \DateTime::createFromInterface($immutable);
 } catch (Throwable $t) {
-	echo $t->getMessage(), "\n";
+	echo $t::class, ': ', $t->getMessage(), "\n";
 }
 
 
 ?>
 --EXPECTF--
-Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor
-Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor
-Object of type DateTimeImmutable has not been correctly initialized by calling parent::__construct() in its constructor
-Object of type DateTimeImmutable has not been correctly initialized by calling parent::__construct() in its constructor
+DateObjectError: Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor
+DateObjectError: Object of type DateTime has not been correctly initialized by calling parent::__construct() in its constructor
+DateObjectError: Object of type DateTimeImmutable has not been correctly initialized by calling parent::__construct() in its constructor
+DateObjectError: Object of type DateTimeImmutable has not been correctly initialized by calling parent::__construct() in its constructor
diff --git a/ext/date/tests/bug51819.phpt b/ext/date/tests/bug51819.phpt
index a5f21abf859e..21db1e774542 100644
--- a/ext/date/tests/bug51819.phpt
+++ b/ext/date/tests/bug51819.phpt
@@ -23,7 +23,7 @@ foreach ($aTz as $sTz) {
     try {
         $oDateTime = new DateTime($sDate);
     } catch (Exception $oException) {
-        var_dump($oException->getMessage());
+        echo $oException::class, ': ', $oException->getMessage(), "\n";
         print_r(DateTime::getLastErrors());
     }
 }
diff --git a/ext/date/tests/bug54283.phpt b/ext/date/tests/bug54283.phpt
index 6acf6e5c8806..c6c303a4d0cc 100644
--- a/ext/date/tests/bug54283.phpt
+++ b/ext/date/tests/bug54283.phpt
@@ -6,7 +6,7 @@ Bug #54283 (new DatePeriod(NULL) causes crash)
 try {
     var_dump(new DatePeriod(NULL));
 } catch (Exception $e) {
-    var_dump($e->getMessage());
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
@@ -14,4 +14,4 @@ try {
 Deprecated: DatePeriod::__construct(): Passing null to parameter #1 ($start) of type string is deprecated in %s on line %d
 
 Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
-string(24) "Unknown or bad format ()"
+DateMalformedPeriodStringException: Unknown or bad format ()
diff --git a/ext/date/tests/bug62500.phpt b/ext/date/tests/bug62500.phpt
index e3a133fb63f5..39ea74cf86c9 100644
--- a/ext/date/tests/bug62500.phpt
+++ b/ext/date/tests/bug62500.phpt
@@ -17,7 +17,7 @@ class Crasher extends DateInterval {
 try {
     $c = new Crasher('blah');
 } catch (Exception $e) {
-    var_dump($e->getMessage());
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECTF--
@@ -26,4 +26,4 @@ int(3)
 
 Warning: Undefined property: Crasher::$2 in %s on line %d
 NULL
-string(28) "Unknown or bad format (blah)"
+DateMalformedIntervalStringException: Unknown or bad format (blah)
diff --git a/ext/date/tests/bug71826.phpt b/ext/date/tests/bug71826.phpt
index 1a4d8ff49f7e..42b0cbf346d3 100644
--- a/ext/date/tests/bug71826.phpt
+++ b/ext/date/tests/bug71826.phpt
@@ -29,4 +29,3 @@ int(28)
 c(Asia/Tokyo): 2015-4-1 <--> 2015-4-29
 int(0)
 int(28)
-
diff --git a/ext/date/tests/bug72963.phpt b/ext/date/tests/bug72963.phpt
index 0fd01808a844..53327f367003 100644
--- a/ext/date/tests/bug72963.phpt
+++ b/ext/date/tests/bug72963.phpt
@@ -16,19 +16,19 @@ foreach ($strings as $string) {
 	try {
 		$d1 = DateTime::createFromFormat('!m/d/Y', $string);
 	} catch (ValueError $v) {
-		echo $v->getMessage(), "\n";
+		echo $v::class, ': ', $v->getMessage(), "\n";
 	}
 
 	try {
 		$d2 = DateTimeImmutable::createFromFormat('!m/d/Y', $string);
 	} catch (ValueError $v) {
-		echo $v->getMessage(), "\n";
+		echo $v::class, ': ', $v->getMessage(), "\n";
 	}
 
 	try {
 		$d3 = date_parse_from_format('m/d/Y', $string);
 	} catch (ValueError $v) {
-		echo $v->getMessage(), "\n";
+		echo $v::class, ': ', $v->getMessage(), "\n";
 	}
 
 	var_dump($d1, $d2, $d3);
@@ -84,9 +84,9 @@ array(12) {
 
 Covering string: 8/8/2016\0asf
 
-DateTime::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
-DateTimeImmutable::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
-date_parse_from_format(): Argument #2 ($datetime) must not contain any null bytes
+ValueError: DateTime::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
+ValueError: DateTimeImmutable::createFromFormat(): Argument #2 ($datetime) must not contain any null bytes
+ValueError: date_parse_from_format(): Argument #2 ($datetime) must not contain any null bytes
 NULL
 NULL
 NULL
diff --git a/ext/date/tests/bug77097.phpt b/ext/date/tests/bug77097.phpt
index 080982d68169..c92fc5d01725 100644
--- a/ext/date/tests/bug77097.phpt
+++ b/ext/date/tests/bug77097.phpt
@@ -30,4 +30,3 @@ float(0.781751)
 int(0)
 int(0)
 float(0.781751)
-
diff --git a/ext/date/tests/bug78139.phpt b/ext/date/tests/bug78139.phpt
index 47e5536cbaad..bd5d07066e5f 100644
--- a/ext/date/tests/bug78139.phpt
+++ b/ext/date/tests/bug78139.phpt
@@ -70,4 +70,3 @@ Parsing 'UTC xx':
 Warning: timezone_open(): Unknown or bad timezone (UTC xx) in %sbug78139.php on line %d
 bool(false)
 DateInvalidTimeZoneException: DateTimeZone::__construct(): Unknown or bad timezone (UTC xx)
-
diff --git a/ext/date/tests/createFromTimestamp.phpt b/ext/date/tests/createFromTimestamp.phpt
index f31aeae11854..cf6c753110b8 100644
--- a/ext/date/tests/createFromTimestamp.phpt
+++ b/ext/date/tests/createFromTimestamp.phpt
@@ -32,14 +32,14 @@ foreach ($timestamps as $ts) {
     try {
         var_dump(DateTime::createFromTimestamp($ts));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
 
     echo 'DateTimeImmutable::createFromTimestamp(' . var_export($ts, true) . '): ';
     try {
         var_dump(DateTimeImmutable::createFromTimestamp($ts));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
 }
 
@@ -47,14 +47,14 @@ echo 'MyDateTime::createFromTimestamp(' . var_export(0, true) . '): ';
 try {
     var_dump(MyDateTime::createFromTimestamp(0));
 } catch (Throwable $e) {
-    echo get_class($e) . ': ' . $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 echo 'MyDateTimeImmutable::createFromTimestamp(' . var_export(0, true) . '): ';
 try {
     var_dump(MyDateTimeImmutable::createFromTimestamp(0));
 } catch (Throwable $e) {
-    echo get_class($e) . ': ' . $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
diff --git a/ext/date/tests/date_interval_set_state_error1.phpt b/ext/date/tests/date_interval_set_state_error1.phpt
index ee68de8db466..4bb71320997f 100644
--- a/ext/date/tests/date_interval_set_state_error1.phpt
+++ b/ext/date/tests/date_interval_set_state_error1.phpt
@@ -14,7 +14,7 @@ try {
         ]
     );
 } catch (Error $e) {
-    echo $e->getMessage() . "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 var_dump($interval);
@@ -43,7 +43,7 @@ object(DateInterval)#%d (%d) {
   ["from_string"]=>
   bool(false)
 }
-Unknown or bad format (wrong) at position 0 (w) while unserializing: The timezone could not be found in the database
+Error: Unknown or bad format (wrong) at position 0 (w) while unserializing: The timezone could not be found in the database
 object(DateInterval)#%d (%d) {
   ["y"]=>
   int(1)
diff --git a/ext/date/tests/date_period_exclude_start_and_include_end.phpt b/ext/date/tests/date_period_exclude_start_and_include_end.phpt
index 6238f6707351..bcfd89eb5c18 100644
--- a/ext/date/tests/date_period_exclude_start_and_include_end.phpt
+++ b/ext/date/tests/date_period_exclude_start_and_include_end.phpt
@@ -16,4 +16,3 @@ foreach ($dp as $day) {
 2010-06-08
 2010-06-09
 2010-06-10
-
diff --git a/ext/date/tests/date_period_unset_property.phpt b/ext/date/tests/date_period_unset_property.phpt
index 7948d61d268d..ced092c768bc 100644
--- a/ext/date/tests/date_period_unset_property.phpt
+++ b/ext/date/tests/date_period_unset_property.phpt
@@ -14,58 +14,58 @@ unset($period->prop);
 try {
     $period->prop;
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->start);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->current);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->end);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->interval);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->recurrences);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->include_start_date);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     unset($period->include_end_date);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-Typed property MyDatePeriod::$prop must not be accessed before initialization
-Cannot unset MyDatePeriod::$start
-Cannot unset MyDatePeriod::$current
-Cannot unset MyDatePeriod::$end
-Cannot unset MyDatePeriod::$interval
-Cannot unset MyDatePeriod::$recurrences
-Cannot unset MyDatePeriod::$include_start_date
-Cannot unset MyDatePeriod::$include_end_date
+Error: Typed property MyDatePeriod::$prop must not be accessed before initialization
+Error: Cannot unset MyDatePeriod::$start
+Error: Cannot unset MyDatePeriod::$current
+Error: Cannot unset MyDatePeriod::$end
+Error: Cannot unset MyDatePeriod::$interval
+Error: Cannot unset MyDatePeriod::$recurrences
+Error: Cannot unset MyDatePeriod::$include_start_date
+Error: Cannot unset MyDatePeriod::$include_end_date
diff --git a/ext/date/tests/date_sunrise_and_sunset_error.phpt b/ext/date/tests/date_sunrise_and_sunset_error.phpt
index 01212992d8fb..0e756f505497 100644
--- a/ext/date/tests/date_sunrise_and_sunset_error.phpt
+++ b/ext/date/tests/date_sunrise_and_sunset_error.phpt
@@ -6,19 +6,19 @@ Test error condition of date_sunrise() and date_sunset()
 try {
     date_sunrise(time(), 3);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 try {
     date_sunset(time(), 4);
 } catch (ValueError $exception) {
-    echo $exception->getMessage() . "\n";
+    echo $exception::class, ': ', $exception->getMessage(), "\n";
 }
 
 ?>
 --EXPECTF--
 Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
-date_sunrise(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
+ValueError: date_sunrise(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
 
 Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d
-date_sunset(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
+ValueError: date_sunset(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE
diff --git a/ext/date/tests/getSetMicroseconds.phpt b/ext/date/tests/getSetMicroseconds.phpt
index debb5459633a..8f4aa864756c 100644
--- a/ext/date/tests/getSetMicroseconds.phpt
+++ b/ext/date/tests/getSetMicroseconds.phpt
@@ -37,7 +37,7 @@ foreach ($microsecondList as $microsecond) {
     try {
         var_dump($dt->setMicrosecond($microsecond));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     echo 'DateTime::getMicrosecond(): ' . var_export($dt->getMicrosecond(), true) . "\n";
 
@@ -45,7 +45,7 @@ foreach ($microsecondList as $microsecond) {
     try {
         var_dump($dti->setMicrosecond($microsecond));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     echo 'DateTimeImmutable::getMicrosecond(): ' . var_export($dti->getMicrosecond(), true) . "\n";
 
@@ -53,7 +53,7 @@ foreach ($microsecondList as $microsecond) {
     try {
         var_dump($myDt->setMicrosecond($microsecond));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     echo 'MyDateTime::getMicrosecond(): ' . var_export($myDt->getMicrosecond(), true) . "\n";
 
@@ -61,7 +61,7 @@ foreach ($microsecondList as $microsecond) {
     try {
         var_dump($myDti->setMicrosecond($microsecond));
     } catch (Throwable $e) {
-        echo get_class($e) . ': ' . $e->getMessage() . "\n";
+        echo $e::class, ': ', $e->getMessage(), "\n";
     }
     echo 'MyDateTimeImmutable::getMicrosecond(): ' . var_export($myDti->getMicrosecond(), true) . "\n";
 }
diff --git a/ext/date/tests/gh14732.phpt b/ext/date/tests/gh14732.phpt
index 19b5f3b481f4..39f3116379e9 100644
--- a/ext/date/tests/gh14732.phpt
+++ b/ext/date/tests/gh14732.phpt
@@ -5,31 +5,31 @@ GH-14732 (date_sun_info() fails for non-finite values)
 try {
     date_sun_info(1, NAN, 1);
 } catch (ValueError $ex) {
-    echo $ex->getMessage(), "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 try {
     date_sun_info(1, -INF, 1);
 } catch (ValueError $ex) {
-    echo $ex->getMessage(), "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 try {
     date_sun_info(1, 1, NAN);
 } catch (ValueError $ex) {
-    echo $ex->getMessage(), "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 try {
     date_sun_info(1, 1, INF);
 } catch (ValueError $ex) {
-    echo $ex->getMessage(), "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 var_dump(date_sunset(1, SUNFUNCS_RET_STRING, NAN, 1));
 var_dump(date_sunrise(1, SUNFUNCS_RET_STRING, 1, NAN));
 ?>
 --EXPECTF--
-date_sun_info(): Argument #2 ($latitude) must be finite
-date_sun_info(): Argument #2 ($latitude) must be finite
-date_sun_info(): Argument #3 ($longitude) must be finite
-date_sun_info(): Argument #3 ($longitude) must be finite
+ValueError: date_sun_info(): Argument #2 ($latitude) must be finite
+ValueError: date_sun_info(): Argument #2 ($latitude) must be finite
+ValueError: date_sun_info(): Argument #3 ($longitude) must be finite
+ValueError: date_sun_info(): Argument #3 ($longitude) must be finite
 
 Deprecated: Constant SUNFUNCS_RET_STRING is deprecated since 8.4, as date_sunrise() and date_sunset() were deprecated in 8.1 in %s on line %d
 
diff --git a/ext/date/tests/gh20936.phpt b/ext/date/tests/gh20936.phpt
index e6a525dd4583..10ad79a9d25d 100644
--- a/ext/date/tests/gh20936.phpt
+++ b/ext/date/tests/gh20936.phpt
@@ -7,7 +7,7 @@ $interval = new DateInterval('P2D');
 try {
     DatePeriod::__set_state(['start' => null, 'end' => $end, 'current' => null, 'interval' => $interval, 'recurrences' => 2, 'include_start_date' => false, 'include_end_date' => true]);
 } catch (Throwable $e) {
-    echo $e::class, ": ", $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 ?>
 --EXPECT--
diff --git a/ext/date/tests/instantiate_uninstantiable_classes.phpt b/ext/date/tests/instantiate_uninstantiable_classes.phpt
index 634ed635b2d2..b14be57ec404 100644
--- a/ext/date/tests/instantiate_uninstantiable_classes.phpt
+++ b/ext/date/tests/instantiate_uninstantiable_classes.phpt
@@ -18,65 +18,65 @@ abstract class MyDateTimeImmutable extends DateTimeImmutable {
 try {
     MyDatePeriod::createFromISO8601String('R5');
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTime::createFromFormat('Y-m-d', '2025-01-01');
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTime::createFromImmutable(new DateTimeImmutable());
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTime::createFromInterface(new DateTimeImmutable());
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTime::createFromTimestamp(0);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTimeImmutable::createFromFormat('Y-m-d', '2025-01-01');
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTimeImmutable::createFromMutable(new DateTime());
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTimeImmutable::createFromInterface(new DateTime());
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 try {
     MyDateTimeImmutable::createFromTimestamp(0);
 } catch (Error $e) {
-    echo $e->getMessage(), "\n";
+    echo $e::class, ': ', $e->getMessage(), "\n";
 }
 
 ?>
 --EXPECT--
-Cannot instantiate abstract class MyDatePeriod
-Cannot instantiate abstract class MyDateTime
-Cannot instantiate abstract class MyDateTime
-Cannot instantiate abstract class MyDateTime
-Cannot instantiate abstract class MyDateTime
-Cannot instantiate abstract class MyDateTimeImmutable
-Cannot instantiate abstract class MyDateTimeImmutable
-Cannot instantiate abstract class MyDateTimeImmutable
-Cannot instantiate abstract class MyDateTimeImmutable
+Error: Cannot instantiate abstract class MyDatePeriod
+Error: Cannot instantiate abstract class MyDateTime
+Error: Cannot instantiate abstract class MyDateTime
+Error: Cannot instantiate abstract class MyDateTime
+Error: Cannot instantiate abstract class MyDateTime
+Error: Cannot instantiate abstract class MyDateTimeImmutable
+Error: Cannot instantiate abstract class MyDateTimeImmutable
+Error: Cannot instantiate abstract class MyDateTimeImmutable
+Error: Cannot instantiate abstract class MyDateTimeImmutable
diff --git a/ext/date/tests/timezone_offset_get_error.phpt b/ext/date/tests/timezone_offset_get_error.phpt
index 4b5cda104ef6..efa5f353ba38 100644
--- a/ext/date/tests/timezone_offset_get_error.phpt
+++ b/ext/date/tests/timezone_offset_get_error.phpt
@@ -14,22 +14,19 @@ $invalid_obj = new stdClass();
 try {
     var_dump( timezone_offset_get($invalid_obj, $date) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 $invalid_obj = 10;
 try {
     var_dump( timezone_offset_get($invalid_obj, $date) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 $invalid_obj = null;
 try {
     var_dump( timezone_offset_get($invalid_obj, $date) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 
 echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n";
@@ -37,38 +34,30 @@ $invalid_obj = new stdClass();
 try {
     var_dump( timezone_offset_get($tz, $invalid_obj) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 $invalid_obj = 10;
 try {
     var_dump( timezone_offset_get($tz, $invalid_obj) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 $invalid_obj = null;
 try {
     var_dump( timezone_offset_get($tz, $invalid_obj) );
 } catch (Error $ex) {
-    var_dump($ex->getMessage());
-    echo "\n";
+    echo $ex::class, ': ', $ex->getMessage(), "\n";
 }
 ?>
 --EXPECT--
 *** Testing timezone_offset_get() : error conditions ***
 
 -- Testing timezone_offset_get() function with an invalid values for $object argument --
-string(89) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, stdClass given"
-
-string(84) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, int given"
-
-string(85) "timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, null given"
-
+TypeError: timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, stdClass given
+TypeError: timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, int given
+TypeError: timezone_offset_get(): Argument #1 ($object) must be of type DateTimeZone, null given
 
 -- Testing timezone_offset_get() function with an invalid values for $datetime argument --
-string(96) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, stdClass given"
-
-string(91) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, int given"
-
-string(92) "timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, null given"
+TypeError: timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, stdClass given
+TypeError: timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, int given
+TypeError: timezone_offset_get(): Argument #2 ($datetime) must be of type DateTimeInterface, null given
diff --git a/ext/date/tests/unserialize-test.phpt b/ext/date/tests/unserialize-test.phpt
index aaff75db6b77..bf3bd117c0cc 100644
--- a/ext/date/tests/unserialize-test.phpt
+++ b/ext/date/tests/unserialize-test.phpt
@@ -17,7 +17,7 @@ foreach ($files as $file) {
 	try {
 		$x = unserialize(substr($s, strpos($s, "|") + 1));
 	} catch (Error $e) {
-		echo get_class($e), ': ', $e->getMessage(), "\n";
+		echo $e::class, ': ', $e->getMessage(), "\n";
 	}
 	var_dump($x);
 	echo "\n\n";
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.