Commit 4ba23348c8f for php.net
commit 4ba23348c8f582adb42298bfbb6a23469afc8939
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Fri Aug 14 16:21:47 2026 +0700
ext/gd: applied fixers to improve test robustness (#23132)
diff --git a/ext/gd/tests/avif_decode_encode.phpt b/ext/gd/tests/avif_decode_encode.phpt
index 054eb524676..d412309bc18 100644
--- a/ext/gd/tests/avif_decode_encode.phpt
+++ b/ext/gd/tests/avif_decode_encode.phpt
@@ -39,7 +39,7 @@
try {
imageavif($img, $outfile, 1234);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
echo 'Encoding AVIF with illegal speed: ';
@@ -47,7 +47,7 @@
try {
imageavif($img, $outfile, 70, 1234);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
echo 'Encoding AVIF losslessly... ';
@@ -75,8 +75,8 @@ function echo_status($success) {
Encoding AVIF at quality 70: ok
Encoding AVIF at quality 70 with speed 5: ok
Encoding AVIF with default quality: ok
-Encoding AVIF with illegal quality: imageavif(): Argument #3 ($quality) must be between -1 and 100
-Encoding AVIF with illegal speed: imageavif(): Argument #4 ($speed) must be between -1 and 10
+Encoding AVIF with illegal quality: ValueError: imageavif(): Argument #3 ($quality) must be between -1 and 100
+Encoding AVIF with illegal speed: ValueError: imageavif(): Argument #4 ($speed) must be between -1 and 10
Encoding AVIF losslessly... ok
Decoding the AVIF we just wrote...
What is the mean squared error of the two images? 0
diff --git a/ext/gd/tests/bug66356.phpt b/ext/gd/tests/bug66356.phpt
index 616a270115c..b82eb03958d 100644
--- a/ext/gd/tests/bug66356.phpt
+++ b/ext/gd/tests/bug66356.phpt
@@ -13,7 +13,7 @@
try {
imagecrop($img, $arr);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
print_r($arr);
@@ -32,7 +32,7 @@
--EXPECTF--
object(GdImage)#2 (0) {
}
-imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
+ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
Array
(
[x] => 2147483647
diff --git a/ext/gd/tests/bug72337.phpt b/ext/gd/tests/bug72337.phpt
index a15fa349304..4973b39eb28 100644
--- a/ext/gd/tests/bug72337.phpt
+++ b/ext/gd/tests/bug72337.phpt
@@ -8,23 +8,23 @@
try {
imagescale($im, 1, 1, -10);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagescale($im, 0, 1, 0);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagescale($im, 1, 0, 0);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
imagescale($im, 1, 1, IMG_BICUBIC_FIXED);
echo "OK";
?>
--EXPECT--
-imagescale(): Argument #4 ($mode) must be one of the GD_* constants
-imagescale(): Argument #2 ($width) must be between 1 and 2147483647
-imagescale(): Argument #3 ($height) must be between 1 and 2147483647
+ValueError: imagescale(): Argument #4 ($mode) must be one of the GD_* constants
+ValueError: imagescale(): Argument #2 ($width) must be between 1 and 2147483647
+ValueError: imagescale(): Argument #3 ($height) must be between 1 and 2147483647
OK
diff --git a/ext/gd/tests/bug72709.phpt b/ext/gd/tests/bug72709.phpt
index bc20d1bf58b..7d9e34ecdab 100644
--- a/ext/gd/tests/bug72709.phpt
+++ b/ext/gd/tests/bug72709.phpt
@@ -10,12 +10,12 @@
var_dump(imagesetstyle($im, array()));
}
catch (\Error $ex) {
- echo $ex->getMessage() . "\n";
+ echo $ex::class, ': ', $ex->getMessage(), "\n";
}
imagesetpixel($im, 0, 0, IMG_COLOR_STYLED);
?>
====DONE====
--EXPECT--
-imagesetstyle(): Argument #2 ($style) must not be empty
+ValueError: imagesetstyle(): Argument #2 ($style) must not be empty
====DONE====
diff --git a/ext/gd/tests/bug73957.phpt b/ext/gd/tests/bug73957.phpt
index 067d71674eb..986adafa076 100644
--- a/ext/gd/tests/bug73957.phpt
+++ b/ext/gd/tests/bug73957.phpt
@@ -15,8 +15,8 @@
// which is not supposed to happen
var_dump(imagesx($im));
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-imagescale(): Argument #2 ($width) must be between 1 and %d
+ValueError: imagescale(): Argument #2 ($width) must be between 1 and %d
diff --git a/ext/gd/tests/bug81739.phpt b/ext/gd/tests/bug81739.phpt
index b340aa7c075..c7f6a4054bf 100644
--- a/ext/gd/tests/bug81739.phpt
+++ b/ext/gd/tests/bug81739.phpt
@@ -19,4 +19,4 @@
in %s on line %d
Warning: imageloadfont(): Error reading font, invalid font header in %s on line %d
-bool(false)
\ No newline at end of file
+bool(false)
diff --git a/ext/gd/tests/colorclosest.phpt b/ext/gd/tests/colorclosest.phpt
index 8cfcbdcdea4..2a189830461 100644
--- a/ext/gd/tests/colorclosest.phpt
+++ b/ext/gd/tests/colorclosest.phpt
@@ -15,7 +15,7 @@
try {
imagecolorsforindex($im, $c);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
$im = null;
@@ -53,7 +53,7 @@
try {
imagecolorsforindex($im, $c);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
$im = null;
@@ -82,7 +82,7 @@
?>
--EXPECT--
FF00FF
-imagecolorsforindex(): Argument #2 ($color) is out of range
+ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range
Array
(
[red] => 255
@@ -105,7 +105,7 @@
[alpha] => 0
)
64FF00FF
-imagecolorsforindex(): Argument #2 ($color) is out of range
+ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range
Array
(
[red] => 255
diff --git a/ext/gd/tests/colormatch.phpt b/ext/gd/tests/colormatch.phpt
index fe22784c994..a2def011c48 100644
--- a/ext/gd/tests/colormatch.phpt
+++ b/ext/gd/tests/colormatch.phpt
@@ -11,11 +11,11 @@
try {
imagecolormatch($im, $im2);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
echo "ok\n";
?>
--EXPECT--
-imagecolormatch(): Argument #2 ($image2) must have at least one color
+ValueError: imagecolormatch(): Argument #2 ($image2) must have at least one color
ok
diff --git a/ext/gd/tests/createfromstring.phpt b/ext/gd/tests/createfromstring.phpt
index ce90b368f2e..569fc0dd41b 100644
--- a/ext/gd/tests/createfromstring.phpt
+++ b/ext/gd/tests/createfromstring.phpt
@@ -55,7 +55,7 @@
try {
imagecreatefromstring('');
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
//random string > 12
$im = imagecreatefromstring(' asdf jklp foo');
diff --git a/ext/gd/tests/gdimage_prevent_cloning.phpt b/ext/gd/tests/gdimage_prevent_cloning.phpt
index 609e6f99bbf..22a4120be0b 100644
--- a/ext/gd/tests/gdimage_prevent_cloning.phpt
+++ b/ext/gd/tests/gdimage_prevent_cloning.phpt
@@ -9,7 +9,7 @@
$img_src = imagecreatetruecolor(32, 32);
$img_dst = clone $img_src;
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
diff --git a/ext/gd/tests/gh16255.phpt b/ext/gd/tests/gh16255.phpt
index 147dc5adf37..c255f1027e3 100644
--- a/ext/gd/tests/gh16255.phpt
+++ b/ext/gd/tests/gh16255.phpt
@@ -12,23 +12,23 @@
try {
imageconvolution($im, $matrix, NAN, 1.0);
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
imageconvolution($im, $matrix, 2.225E-307, 1.0);
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
imageconvolution($im, $matrix, 1, NAN);
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imageconvolution(): Argument #3 ($divisor) must be finite
-imageconvolution(): Argument #3 ($divisor) must not be 0
-imageconvolution(): Argument #4 ($offset) must be finite
+ValueError: imageconvolution(): Argument #3 ($divisor) must be finite
+ValueError: imageconvolution(): Argument #3 ($divisor) must not be 0
+ValueError: imageconvolution(): Argument #4 ($offset) must be finite
diff --git a/ext/gd/tests/gh16260.phpt b/ext/gd/tests/gh16260.phpt
index 563fc8d1627..57daf82b387 100644
--- a/ext/gd/tests/gh16260.phpt
+++ b/ext/gd/tests/gh16260.phpt
@@ -9,14 +9,14 @@
try {
imagerotate($im, PHP_INT_MIN, 0);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagerotate($im, PHP_INT_MAX, 0);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
--EXPECTF--
-imagerotate(): Argument #2 ($angle) must be between %s and %s
-imagerotate(): Argument #2 ($angle) must be between %s and %s
+ValueError: imagerotate(): Argument #2 ($angle) must be between %s and %s
+ValueError: imagerotate(): Argument #2 ($angle) must be between %s and %s
diff --git a/ext/gd/tests/gh16322.phpt b/ext/gd/tests/gh16322.phpt
index 1e5ab2f3a6b..abe6846b172 100644
--- a/ext/gd/tests/gh16322.phpt
+++ b/ext/gd/tests/gh16322.phpt
@@ -10,16 +10,16 @@
try {
imageaffine($src, $matrix);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$matrix[0] = 1;
$matrix[3] = -INF;
try {
imageaffine($src, $matrix);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-imageaffine(): Argument #2 ($affine) element 0 must be between %s and %d
-imageaffine(): Argument #2 ($affine) element 3 must be between %s and %d
+ValueError: imageaffine(): Argument #2 ($affine) element 0 must be between %s and %d
+ValueError: imageaffine(): Argument #2 ($affine) element 3 must be between %s and %d
diff --git a/ext/gd/tests/gh17703.phpt b/ext/gd/tests/gh17703.phpt
index 4677b6a5013..9d9145f30e0 100644
--- a/ext/gd/tests/gh17703.phpt
+++ b/ext/gd/tests/gh17703.phpt
@@ -10,8 +10,8 @@
try {
imagescale($img, -1, -1, 0);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
-Argument #2 ($width) and argument #3 ($height) cannot be both negative
+ValueError: Argument #2 ($width) and argument #3 ($height) cannot be both negative
diff --git a/ext/gd/tests/gh18005.phpt b/ext/gd/tests/gh18005.phpt
index 5282c0be026..e36d2efa2cd 100644
--- a/ext/gd/tests/gh18005.phpt
+++ b/ext/gd/tests/gh18005.phpt
@@ -13,80 +13,80 @@ class A {}
try {
imagesetstyle($img, [0, new A()]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagesetstyle($img, [0, PHP_INT_MIN]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagefilter($img, IMG_FILTER_SCATTER, 0, 0, [new A()]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagefilter($img, IMG_FILTER_SCATTER, 0, 0, [-1]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => PHP_INT_MIN, "y" => 0, "width" => 0, "height" => 0]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => PHP_INT_MIN, "width" => 0, "height" => 0]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => 0, "width" => PHP_INT_MAX, "height" => 0]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => 0, "width" => 0, "height" => PHP_INT_MAX]);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => new A(), "y" => 0, "width" => 0, "height" => 0]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => new A(), "width" => 0, "height" => 0]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => 0, "width" => new A(), "height" => 0]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagecrop($img, ["x" => 0, "y" => 0, "width" => 0, "height" => new A()]);
} catch (\TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$one = 1;
var_dump(imagecrop($img, ["x" => &$one, "y" => &$one, "width" => &$one, "height" => &$one]));
?>
--EXPECTF--
-imagesetstyle(): Argument #2 ($style) must only have elements of type int, A given
-imagesetstyle(): Argument #2 ($style) elements must be between %i and %d
-imagefilter(): Argument #5 must be of type int, A given
-imagefilter(): Argument #5 value must be between 0 and 2147483647
-imagecrop(): Argument #2 ($rectangle) "x" key must be between %i and %d
-imagecrop(): Argument #2 ($rectangle) "y" key must be between %i and %d
-imagecrop(): Argument #2 ($rectangle) "width" key must be between %i and %d
-imagecrop(): Argument #2 ($rectangle) "height" key must be between %i and %d
-imagecrop(): Argument #2 ($rectangle) "x" key must be of type int, A given
-imagecrop(): Argument #2 ($rectangle) "y" key must be of type int, A given
-imagecrop(): Argument #2 ($rectangle) "width" key must be of type int, A given
-imagecrop(): Argument #2 ($rectangle) "height" key must be of type int, A given
+TypeError: imagesetstyle(): Argument #2 ($style) must only have elements of type int, A given
+ValueError: imagesetstyle(): Argument #2 ($style) elements must be between %i and %d
+TypeError: imagefilter(): Argument #5 must be of type int, A given
+ValueError: imagefilter(): Argument #5 value must be between 0 and 2147483647
+ValueError: imagecrop(): Argument #2 ($rectangle) "x" key must be between %i and %d
+ValueError: imagecrop(): Argument #2 ($rectangle) "y" key must be between %i and %d
+ValueError: imagecrop(): Argument #2 ($rectangle) "width" key must be between %i and %d
+ValueError: imagecrop(): Argument #2 ($rectangle) "height" key must be between %i and %d
+TypeError: imagecrop(): Argument #2 ($rectangle) "x" key must be of type int, A given
+TypeError: imagecrop(): Argument #2 ($rectangle) "y" key must be of type int, A given
+TypeError: imagecrop(): Argument #2 ($rectangle) "width" key must be of type int, A given
+TypeError: imagecrop(): Argument #2 ($rectangle) "height" key must be of type int, A given
object(GdImage)#2 (0) {
}
diff --git a/ext/gd/tests/gh18243.phpt b/ext/gd/tests/gh18243.phpt
index 3235098a3dc..00698add614 100644
--- a/ext/gd/tests/gh18243.phpt
+++ b/ext/gd/tests/gh18243.phpt
@@ -14,29 +14,29 @@
try {
imagettftext($im, PHP_INT_MAX, 0, 15, 60, 0, $font, "");
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagettftext($im, PHP_INT_MIN, 0, 15, 60, 0, $font, "");
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagettftext($im, NAN, 0, 15, 60, 0, $font, "");
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagettftext($im, INF, 0, 15, 60, 0, $font, "");
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-imagettftext(): Argument #2 ($size) must be between %i and %d
-imagettftext(): Argument #2 ($size) must be between %i and %d
-imagettftext(): Argument #2 ($size) must be finite
-imagettftext(): Argument #2 ($size) must be between %i and %d
+ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d
+ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d
+ValueError: imagettftext(): Argument #2 ($size) must be finite
+ValueError: imagettftext(): Argument #2 ($size) must be between %i and %d
diff --git a/ext/gd/tests/gh19578.phpt b/ext/gd/tests/gh19578.phpt
index 15d10f752d0..cc13c646792 100644
--- a/ext/gd/tests/gh19578.phpt
+++ b/ext/gd/tests/gh19578.phpt
@@ -13,15 +13,15 @@
try {
imagefilledellipse($src, 0, 0, PHP_INT_MAX, 254, 0);
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagefilledellipse($src, 0, 0, -16, 254, 0);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
-imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
+ValueError: imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
+ValueError: imagefilledellipse(): Argument #4 ($width) must be between 0 and %d
diff --git a/ext/gd/tests/gh20551.phpt b/ext/gd/tests/gh20551.phpt
index 32ca50ca5f6..04a62a256df 100644
--- a/ext/gd/tests/gh20551.phpt
+++ b/ext/gd/tests/gh20551.phpt
@@ -21,16 +21,16 @@
try {
imagegammacorrect($im, $gamma[0], $gamma[1]);
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
}
?>
--EXPECT--
-imagegammacorrect(): Argument #2 ($input_gamma) must be finite
-imagegammacorrect(): Argument #2 ($input_gamma) must be finite
-imagegammacorrect(): Argument #2 ($input_gamma) must be finite
-imagegammacorrect(): Argument #2 ($input_gamma) must be greater than 0
-imagegammacorrect(): Argument #3 ($output_gamma) must be finite
-imagegammacorrect(): Argument #3 ($output_gamma) must be finite
-imagegammacorrect(): Argument #3 ($output_gamma) must be finite
-imagegammacorrect(): Argument #3 ($output_gamma) must be greater than 0
+ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #2 ($input_gamma) must be greater than 0
+ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be finite
+ValueError: imagegammacorrect(): Argument #3 ($output_gamma) must be greater than 0
diff --git a/ext/gd/tests/gh20602.phpt b/ext/gd/tests/gh20602.phpt
index 29c781e76a2..b481b32ae9b 100644
--- a/ext/gd/tests/gh20602.phpt
+++ b/ext/gd/tests/gh20602.phpt
@@ -9,14 +9,14 @@
try {
imagescale($im, PHP_INT_MAX, -1);
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagescale($im, -1, PHP_INT_MAX);
} catch (\ValueError $e) {
- echo $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-imagescale(): Argument #2 ($width) must be less than or equal to %d
-imagescale(): Argument #3 ($height) must be less than or equal to %d
+ValueError: imagescale(): Argument #2 ($width) must be less than or equal to %d
+ValueError: imagescale(): Argument #3 ($height) must be less than or equal to %d
diff --git a/ext/gd/tests/gh8848.phpt b/ext/gd/tests/gh8848.phpt
index 0e18b64babb..324307f5596 100644
--- a/ext/gd/tests/gh8848.phpt
+++ b/ext/gd/tests/gh8848.phpt
@@ -18,12 +18,12 @@
try {
imagecopyresized($image1, $image2, 1, 1, 1, 1, ...$args);
} catch (ValueError $ex) {
- echo $ex->getMessage(), PHP_EOL;
+ echo $ex::class, ': ', $ex->getMessage(), PHP_EOL;
}
}
?>
--EXPECT--
-imagecopyresized(): Argument #7 ($dst_width) must be greater than 0
-imagecopyresized(): Argument #8 ($dst_height) must be greater than 0
-imagecopyresized(): Argument #9 ($src_width) must be greater than 0
-imagecopyresized(): Argument #10 ($src_height) must be greater than 0
+ValueError: imagecopyresized(): Argument #7 ($dst_width) must be greater than 0
+ValueError: imagecopyresized(): Argument #8 ($dst_height) must be greater than 0
+ValueError: imagecopyresized(): Argument #9 ($src_width) must be greater than 0
+ValueError: imagecopyresized(): Argument #10 ($src_height) must be greater than 0
diff --git a/ext/gd/tests/imagebmp_nullbyte_injection.phpt b/ext/gd/tests/imagebmp_nullbyte_injection.phpt
index 81a3e40d7c2..2fe4aa9b34e 100644
--- a/ext/gd/tests/imagebmp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagebmp_nullbyte_injection.phpt
@@ -12,8 +12,8 @@
try {
imagebmp($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagebmp(): Argument #2 ($file) must not contain null bytes
+TypeError: imagebmp(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imagecolormatch_error2.phpt b/ext/gd/tests/imagecolormatch_error2.phpt
index 5af039a785d..c2cdc0b9158 100644
--- a/ext/gd/tests/imagecolormatch_error2.phpt
+++ b/ext/gd/tests/imagecolormatch_error2.phpt
@@ -15,9 +15,9 @@
try {
imagecolormatch($ima, $imb);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-imagecolormatch(): Argument #1 ($image1) must be TrueColor
+ValueError: imagecolormatch(): Argument #1 ($image1) must be TrueColor
diff --git a/ext/gd/tests/imagecolormatch_error3.phpt b/ext/gd/tests/imagecolormatch_error3.phpt
index 9b0d4c8830c..02101585b97 100644
--- a/ext/gd/tests/imagecolormatch_error3.phpt
+++ b/ext/gd/tests/imagecolormatch_error3.phpt
@@ -15,9 +15,9 @@
try {
imagecolormatch($ima, $imb);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-imagecolormatch(): Argument #2 ($image2) must be Palette
+ValueError: imagecolormatch(): Argument #2 ($image2) must be Palette
diff --git a/ext/gd/tests/imagecolormatch_error4.phpt b/ext/gd/tests/imagecolormatch_error4.phpt
index e4aa04ca3d3..2c117dcd46a 100644
--- a/ext/gd/tests/imagecolormatch_error4.phpt
+++ b/ext/gd/tests/imagecolormatch_error4.phpt
@@ -15,9 +15,9 @@
try {
imagecolormatch($ima, $imb);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($im1)
+ValueError: imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($im1)
diff --git a/ext/gd/tests/imagecrop_overflow.phpt b/ext/gd/tests/imagecrop_overflow.phpt
index 3331a626716..4edfb985ae9 100644
--- a/ext/gd/tests/imagecrop_overflow.phpt
+++ b/ext/gd/tests/imagecrop_overflow.phpt
@@ -11,7 +11,7 @@
try {
imagecrop($img, $arr);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$arr = ["x" => -2147483648, "y" => 0, "width" => -10, "height" => 10];
@@ -19,7 +19,7 @@
try {
imagecrop($img, $arr);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$arr = ["x" => 1, "y" => 2147483647, "width" => 10, "height" => 10];
@@ -27,7 +27,7 @@
try {
imagecrop($img, $arr);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
$arr = ["x" => 1, "y" => -2147483648, "width" => 10, "height" => -10];
@@ -35,11 +35,11 @@
try {
imagecrop($img, $arr);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
-imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
-imagecrop(): Argument #2 ($rectangle) underflow with "x" and "width" keys
-imagecrop(): Argument #2 ($rectangle) overflow with "y" and "height" keys
-imagecrop(): Argument #2 ($rectangle) underflow with "y" and "height" keys
+ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "x" and "width" keys
+ValueError: imagecrop(): Argument #2 ($rectangle) underflow with "x" and "width" keys
+ValueError: imagecrop(): Argument #2 ($rectangle) overflow with "y" and "height" keys
+ValueError: imagecrop(): Argument #2 ($rectangle) underflow with "y" and "height" keys
diff --git a/ext/gd/tests/imagefilter2.phpt b/ext/gd/tests/imagefilter2.phpt
index 99b73ffc133..5f0ec6615ae 100644
--- a/ext/gd/tests/imagefilter2.phpt
+++ b/ext/gd/tests/imagefilter2.phpt
@@ -20,17 +20,17 @@
try {
imagefilter($im, IMG_FILTER_SCATTER, $val, 0);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagefilter($im, IMG_FILTER_SCATTER, 0, $val);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
}
?>
--EXPECTF--
-imagefilter(): Argument #3 must be between 0 and %d
-imagefilter(): Argument #4 must be between 0 and %d
-imagefilter(): Argument #3 must be between 0 and %d
-imagefilter(): Argument #4 must be between 0 and %d
+ValueError: imagefilter(): Argument #3 must be between 0 and %d
+ValueError: imagefilter(): Argument #4 must be between 0 and %d
+ValueError: imagefilter(): Argument #3 must be between 0 and %d
+ValueError: imagefilter(): Argument #4 must be between 0 and %d
diff --git a/ext/gd/tests/imagefilter_error1.phpt b/ext/gd/tests/imagefilter_error1.phpt
index cc9904e320d..f2e6e1c3e69 100644
--- a/ext/gd/tests/imagefilter_error1.phpt
+++ b/ext/gd/tests/imagefilter_error1.phpt
@@ -12,14 +12,14 @@
try {
var_dump(imagefilter($image));
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump(imagefilter(20, 1));
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagefilter() expects at least 2 arguments, 1 given
-imagefilter(): Argument #1 ($image) must be of type GdImage, int given
+ArgumentCountError: imagefilter() expects at least 2 arguments, 1 given
+TypeError: imagefilter(): Argument #1 ($image) must be of type GdImage, int given
diff --git a/ext/gd/tests/imagegd2_nullbyte_injection.phpt b/ext/gd/tests/imagegd2_nullbyte_injection.phpt
index 5765543be1d..95995b78b1f 100644
--- a/ext/gd/tests/imagegd2_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagegd2_nullbyte_injection.phpt
@@ -8,8 +8,8 @@
try {
imagegd($image, "./foo\0bar");
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagegd(): Argument #2 ($file) must not contain any null bytes
+ValueError: imagegd(): Argument #2 ($file) must not contain any null bytes
diff --git a/ext/gd/tests/imagegd_nullbyte_injection.phpt b/ext/gd/tests/imagegd_nullbyte_injection.phpt
index 657e11dd178..fe4490acdde 100644
--- a/ext/gd/tests/imagegd_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagegd_nullbyte_injection.phpt
@@ -8,8 +8,8 @@
try {
imagegd($image, "./foo\0bar");
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagegd(): Argument #2 ($file) must not contain any null bytes
+ValueError: imagegd(): Argument #2 ($file) must not contain any null bytes
diff --git a/ext/gd/tests/imagegif_nullbyte_injection.phpt b/ext/gd/tests/imagegif_nullbyte_injection.phpt
index 5cdb6f6879f..a0b98badb2d 100644
--- a/ext/gd/tests/imagegif_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagegif_nullbyte_injection.phpt
@@ -8,8 +8,8 @@
try {
imagegif($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagegif(): Argument #2 ($file) must not contain null bytes
+TypeError: imagegif(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
index 6863626a0c9..1b260de6752 100644
--- a/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagejpeg_nullbyte_injection.phpt
@@ -15,8 +15,8 @@
try {
imagejpeg($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagejpeg(): Argument #2 ($file) must not contain null bytes
+TypeError: imagejpeg(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imagepng_nullbyte_injection.phpt b/ext/gd/tests/imagepng_nullbyte_injection.phpt
index f5ec342b9c6..ca04a5be9e1 100644
--- a/ext/gd/tests/imagepng_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagepng_nullbyte_injection.phpt
@@ -15,8 +15,8 @@
try {
imagepng($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagepng(): Argument #2 ($file) must not contain null bytes
+TypeError: imagepng(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imageresolution_basic.phpt b/ext/gd/tests/imageresolution_basic.phpt
index 74dc8c59dcd..d50173eb74d 100644
--- a/ext/gd/tests/imageresolution_basic.phpt
+++ b/ext/gd/tests/imageresolution_basic.phpt
@@ -18,17 +18,17 @@
try {
imageresolution($exp, PHP_INT_MAX);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imageresolution($exp, 127, -PHP_INT_MAX);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
imageresolution($exp, 0, 0);
var_dump(imageresolution($exp) == $res);
?>
--EXPECTF--
-imageresolution(): Argument #2 ($resolution_x) must be between 0 and %d
-imageresolution(): Argument #3 ($resolution_y) must be between 0 and %d
+ValueError: imageresolution(): Argument #2 ($resolution_x) must be between 0 and %d
+ValueError: imageresolution(): Argument #3 ($resolution_y) must be between 0 and %d
bool(true)
diff --git a/ext/gd/tests/imageresolution_jpeg.phpt b/ext/gd/tests/imageresolution_jpeg.phpt
index 739b6949a87..a918c7402d2 100644
--- a/ext/gd/tests/imageresolution_jpeg.phpt
+++ b/ext/gd/tests/imageresolution_jpeg.phpt
@@ -27,7 +27,7 @@
try {
imagejpeg($exp, $filename, 101);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
@@ -43,7 +43,7 @@
[1]=>
int(299)
}
-imagejpeg(): Argument #3 ($quality) must be at between -1 and 100
+ValueError: imagejpeg(): Argument #3 ($quality) must be at between -1 and 100
--CLEAN--
<?php
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'imageresolution_jpeg.jpeg');
diff --git a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
index 1c25fdab256..625e77a7bbe 100644
--- a/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagewbmp_nullbyte_injection.phpt
@@ -15,8 +15,8 @@
try {
imagewbmp($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagewbmp(): Argument #2 ($file) must not contain null bytes
+TypeError: imagewbmp(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imagewebp_nullbyte_injection.phpt b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
index 3fcb687eeea..27169d6f463 100644
--- a/ext/gd/tests/imagewebp_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagewebp_nullbyte_injection.phpt
@@ -15,8 +15,8 @@
try {
imagewebp($image, "./foo\0bar");
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagewebp(): Argument #2 ($file) must not contain null bytes
+TypeError: imagewebp(): Argument #2 ($file) must not contain null bytes
diff --git a/ext/gd/tests/imagexbm_nullbyte_injection.phpt b/ext/gd/tests/imagexbm_nullbyte_injection.phpt
index 701f910014c..59892a25af5 100644
--- a/ext/gd/tests/imagexbm_nullbyte_injection.phpt
+++ b/ext/gd/tests/imagexbm_nullbyte_injection.phpt
@@ -8,8 +8,8 @@
try {
imagexbm($image, "./foo\0bar");
} catch (ValueError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-imagexbm(): Argument #2 ($filename) must not contain any null bytes
+ValueError: imagexbm(): Argument #2 ($filename) must not contain any null bytes
diff --git a/ext/gd/tests/pngcomp.phpt b/ext/gd/tests/pngcomp.phpt
index 81beacad8a5..c6b65dd0813 100644
--- a/ext/gd/tests/pngcomp.phpt
+++ b/ext/gd/tests/pngcomp.phpt
@@ -18,12 +18,12 @@
try {
imagepng($im, $cwd . '/test_pngcomp.png', -2);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
imagepng($im, $cwd . '/test_pngcomp.png', 10);
} catch (\ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
echo "PNG compression test: ";
imagepng($im, $cwd . '/test_pngcomp.png', 9);
@@ -37,6 +37,6 @@
@unlink($cwd . "/test_pngcomp.png");
?>
--EXPECT--
-imagepng(): Argument #3 ($quality) must be between -1 and 9
-imagepng(): Argument #3 ($quality) must be between -1 and 9
+ValueError: imagepng(): Argument #3 ($quality) must be between -1 and 9
+ValueError: imagepng(): Argument #3 ($quality) must be between -1 and 9
PNG compression test: ok
diff --git a/ext/gd/tests/webp_basic.phpt b/ext/gd/tests/webp_basic.phpt
index ef2fae86525..9f6272c5293 100644
--- a/ext/gd/tests/webp_basic.phpt
+++ b/ext/gd/tests/webp_basic.phpt
@@ -40,7 +40,7 @@
try {
imagewebp($im1, $filename, -10);
} catch (\ValueError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
@@ -51,4 +51,4 @@
--EXPECT--
Is lossy conversion close enough? bool(true)
Does lossless conversion work? bool(true)
-imagewebp(): Argument #3 ($quality) must be greater than or equal to -1
+ValueError: imagewebp(): Argument #3 ($quality) must be greater than or equal to -1