Commit 170ca63f7bb for php.net
commit 170ca63f7bb8c183d55be880c2bd11006543d67a
Author: NickSdot <catch.github.com.nicksdot@nicksdot.dev>
Date: Tue Aug 4 13:03:13 2026 +0000
ext/date: applied fixers to improve test robustness
diff --git a/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt b/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
index f8b1e1cffe4..a5ae7e11b29 100644
--- a/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
+++ b/ext/date/tests/DatePeriod_createFromISO8601String_static_return.phpt
@@ -10,13 +10,13 @@ class MyDatePeriod extends DatePeriod {}
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 @@ class MyDatePeriod extends DatePeriod {}
["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 45f99bdb727..eaf326f842e 100644
--- a/ext/date/tests/DatePeriod_wrong_constructor.phpt
+++ b/ext/date/tests/DatePeriod_wrong_constructor.phpt
@@ -11,8 +11,8 @@
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 31c6868d67f..8e7a57fefe0 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 @@
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 546867924cb..ab8452d5897 100644
--- a/ext/date/tests/bug-gh11416.phpt
+++ b/ext/date/tests/bug-gh11416.phpt
@@ -11,14 +11,14 @@
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 @@
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 @@
]);
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 ab03e190e4b..2dd6ec59b8f 100644
--- a/ext/date/tests/bug-gh15582.phpt
+++ b/ext/date/tests/bug-gh15582.phpt
@@ -14,7 +14,7 @@ function __construct()
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 2f6656849f6..0c1c6941869 100644
--- a/ext/date/tests/bug-gh8471.phpt
+++ b/ext/date/tests/bug-gh8471.phpt
@@ -8,7 +8,7 @@
try {
$immutable = \DateTimeImmutable::createFromMutable($mutable);
} catch (Throwable $t) {
- echo $t->getMessage(), "\n";
+ echo $t::class, ': ', $t->getMessage(), "\n";
}
@@ -18,7 +18,7 @@
try {
$immutable = \DateTimeImmutable::createFromInterface($mutable);
} catch (Throwable $t) {
- echo $t->getMessage(), "\n";
+ echo $t::class, ': ', $t->getMessage(), "\n";
}
@@ -28,7 +28,7 @@
try {
$mutable = \DateTime::createFromImmutable($immutable);
} catch (Throwable $t) {
- echo $t->getMessage(), "\n";
+ echo $t::class, ': ', $t->getMessage(), "\n";
}
@@ -38,13 +38,13 @@
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 a5f21abf859..21db1e77454 100644
--- a/ext/date/tests/bug51819.phpt
+++ b/ext/date/tests/bug51819.phpt
@@ -23,7 +23,7 @@
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 6acf6e5c880..c6c303a4d0c 100644
--- a/ext/date/tests/bug54283.phpt
+++ b/ext/date/tests/bug54283.phpt
@@ -6,7 +6,7 @@
try {
var_dump(new DatePeriod(NULL));
} catch (Exception $e) {
- var_dump($e->getMessage());
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
@@ -14,4 +14,4 @@
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 e3a133fb63f..39ea74cf86c 100644
--- a/ext/date/tests/bug62500.phpt
+++ b/ext/date/tests/bug62500.phpt
@@ -17,7 +17,7 @@ public function __construct($time_spec) {
try {
$c = new Crasher('blah');
} catch (Exception $e) {
- var_dump($e->getMessage());
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
@@ -26,4 +26,4 @@ public function __construct($time_spec) {
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 1a4d8ff49f7..42b0cbf346d 100644
--- a/ext/date/tests/bug71826.phpt
+++ b/ext/date/tests/bug71826.phpt
@@ -29,4 +29,3 @@
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 0fd01808a84..53327f36700 100644
--- a/ext/date/tests/bug72963.phpt
+++ b/ext/date/tests/bug72963.phpt
@@ -16,19 +16,19 @@
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 @@
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 080982d6816..c92fc5d0172 100644
--- a/ext/date/tests/bug77097.phpt
+++ b/ext/date/tests/bug77097.phpt
@@ -30,4 +30,3 @@
int(0)
int(0)
float(0.781751)
-
diff --git a/ext/date/tests/bug78139.phpt b/ext/date/tests/bug78139.phpt
index 47e5536cbaa..bd5d07066e5 100644
--- a/ext/date/tests/bug78139.phpt
+++ b/ext/date/tests/bug78139.phpt
@@ -70,4 +70,3 @@
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 f31aeae1185..cf6c753110b 100644
--- a/ext/date/tests/createFromTimestamp.phpt
+++ b/ext/date/tests/createFromTimestamp.phpt
@@ -32,14 +32,14 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 ee68de8db46..4bb71320997 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 @@
]
);
} catch (Error $e) {
- echo $e->getMessage() . "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($interval);
@@ -43,7 +43,7 @@
["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 6238f670735..bcfd89eb5c1 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 @@
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 7948d61d268..ced092c768b 100644
--- a/ext/date/tests/date_period_unset_property.phpt
+++ b/ext/date/tests/date_period_unset_property.phpt
@@ -14,58 +14,58 @@ class MyDatePeriod extends DatePeriod {
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 01212992d8f..0e756f50549 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 @@
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 debb5459633..8f4aa864756 100644
--- a/ext/date/tests/getSetMicroseconds.phpt
+++ b/ext/date/tests/getSetMicroseconds.phpt
@@ -37,7 +37,7 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 @@ class MyDateTimeImmutable extends DateTimeImmutable {};
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 19b5f3b481f..39f3116379e 100644
--- a/ext/date/tests/gh14732.phpt
+++ b/ext/date/tests/gh14732.phpt
@@ -5,31 +5,31 @@
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 e6a525dd458..10ad79a9d25 100644
--- a/ext/date/tests/gh20936.phpt
+++ b/ext/date/tests/gh20936.phpt
@@ -7,7 +7,7 @@
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 634ed635b2d..b14be57ec40 100644
--- a/ext/date/tests/instantiate_uninstantiable_classes.phpt
+++ b/ext/date/tests/instantiate_uninstantiable_classes.phpt
@@ -18,65 +18,65 @@ public abstract function foo();
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 4b5cda104ef..efa5f353ba3 100644
--- a/ext/date/tests/timezone_offset_get_error.phpt
+++ b/ext/date/tests/timezone_offset_get_error.phpt
@@ -14,22 +14,19 @@
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 @@
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 aaff75db6b7..bf3bd117c0c 100644
--- a/ext/date/tests/unserialize-test.phpt
+++ b/ext/date/tests/unserialize-test.phpt
@@ -17,7 +17,7 @@
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";