result = gdImageColorMatch(im1, im2);
switch (result) {
case -1:
- php_error_docref(NULL, E_WARNING, "Image1 must be TrueColor" );
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be TrueColor");
+ RETURN_THROWS();
break;
case -2:
- php_error_docref(NULL, E_WARNING, "Image2 must be Palette" );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be Palette");
+ RETURN_THROWS();
break;
case -3:
- php_error_docref(NULL, E_WARNING, "Image1 and Image2 must be the same size" );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be the same size as argument #1 ($im1)");
+ RETURN_THROWS();
break;
case -4:
- php_error_docref(NULL, E_WARNING, "Image2 must have at least one color" );
- RETURN_FALSE;
+ zend_argument_value_error(2, "must have at least one color");
+ RETURN_THROWS();
break;
}
im = (*ioctx_func_p)(io_ctx);
if (!im) {
- php_error_docref(NULL, E_WARNING, "Passed data is not in '%s' format", tn);
+ php_error_docref(NULL, E_WARNING, "Passed data is not in \"%s\" format", tn);
io_ctx->gd_free(io_ctx);
return NULL;
}
}
if (ZSTR_LEN(data) < sizeof(sig)) {
- php_error_docref(NULL, E_WARNING, "Empty string or invalid image");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
memcpy(sig, ZSTR_VAL(data), sizeof(sig));
return;
}
- php_error_docref(NULL, E_WARNING, "'%s' is not a valid %s file", file, tn);
+ php_error_docref(NULL, E_WARNING, "\"%s\" is not a valid %s file", file, tn);
out_err:
php_stream_close(stream);
RETURN_FALSE;
fp = VCWD_FOPEN(fn, "wb");
if (!fp) {
- php_error_docref(NULL, E_WARNING, "Unable to open '%s' for writing", fn);
+ php_error_docref(NULL, E_WARNING, "Unable to open \"%s\" for writing", fn);
RETURN_FALSE;
}
add_assoc_long(return_value,"blue", gdImageBlue(im,col));
add_assoc_long(return_value,"alpha", gdImageAlpha(im,col));
} else {
- php_error_docref(NULL, E_WARNING, "Color index %d out of range", col);
- RETURN_FALSE;
+ zend_argument_value_error(2, "is out of range");
+ RETURN_THROWS();
}
}
/* }}} */
Warning: imagecreatefrompng(%s001私はガラスを食べられます.test): Failed to open stream: No such file or directory in %s on line %d
bool(false)
-Warning: imagecreatefrompng(): '%s001私はガラスを食べられます.test' is not a valid PNG file in %s on line %d
+Warning: imagecreatefrompng(): "%s001私はガラスを食べられます.test" is not a valid PNG file in %s on line %d
bool(false)
Done
Warning: imagecreatefrompng(%s001.test): Failed to open stream: No such file or directory in %s on line %d
bool(false)
-Warning: imagecreatefrompng(): '%s001.test' is not a valid PNG file in %s on line %d
+Warning: imagecreatefrompng(): "%s001.test" is not a valid PNG file in %s on line %d
bool(false)
Done
$im = imagecreatefromgif(__DIR__ . '/bug37346私はガラスを食べられます.gif');
?>
--EXPECTF--
-Warning: imagecreatefromgif(): '%sbug37346私はガラスを食べられます.gif' is not a valid GIF file in %sbug37346-mb.php on line %d
+Warning: imagecreatefromgif(): "%sbug37346私はガラスを食べられます.gif" is not a valid GIF file in %sbug37346-mb.php on line %d
$im = imagecreatefromgif(__DIR__ . '/bug37346.gif');
?>
--EXPECTF--
-Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d
+Warning: imagecreatefromgif(): "%sbug37346.gif" is not a valid GIF file in %sbug37346.php on line %d
var_dump($im);
?>
--EXPECTF--
-Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d
+Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d
bool(false)
$im = imagecreatefromgif(__DIR__ . '/bug38112.gif');
?>
--EXPECTF--
-Warning: imagecreatefromgif(): '%sbug38112.gif' is not a valid GIF file in %sbug38112.php on line %d
+Warning: imagecreatefromgif(): "%sbug38112.gif" is not a valid GIF file in %sbug38112.php on line %d
Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d
-Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d
+Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d
bool(false)
--EXPECTF--
gd-png: fatal libpng error: Read Error: truncated data
gd-png error: setjmp returns error condition 2
-Warning: imagecreatefrompng(): '%sbug39780.png' is not a valid PNG file in /%s on line %d
+Warning: imagecreatefrompng(): v%sbug39780.png" is not a valid PNG file in /%s on line %d
bool(false)
?>
OK
--EXPECTF--
-Warning: imagecreatefromgd2(): '%s%einvalid_neg_size私はガラスを食べられます.gd2' is not a valid GD2 file in %s%ebug71912-mb.php on line %d
+Warning: imagecreatefromgd2(): "%s%einvalid_neg_size私はガラスを食べられます.gd2" is not a valid GD2 file in %s%ebug71912-mb.php on line %d
OK
?>
OK
--EXPECTF--
-Warning: imagecreatefromgd2(): '%s%einvalid_neg_size.gd2' is not a valid GD2 file in %s%ebug71912.php on line %d
+Warning: imagecreatefromgd2(): "%s%einvalid_neg_size.gd2" is not a valid GD2 file in %s%ebug71912.php on line %d
OK
Warning: imagecreatefromgd2(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %sbug72339.php on line %d
-Warning: imagecreatefromgd2(): '%sbug72339.gd' is not a valid GD2 file in %sbug72339.php on line %d
+Warning: imagecreatefromgd2(): "%sbug72339.gd" is not a valid GD2 file in %sbug72339.php on line %d
var_dump($im);
?>
--EXPECTF--
-Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
+Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
Warning: imagecreatefromgd2(): gd2: EOF while reading
in %s on line %d
-Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
+Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2'));
?>
--EXPECTF--
-Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
+Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
-Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
+Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
var_dump(imagecreatefromstring($str));
?>
--EXPECTF--
-Warning: imagecreatefromstring(): Passed data is not in 'BMP' format in %s on line %d
+Warning: imagecreatefromstring(): Passed data is not in "BMP" format in %s on line %d
Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in %s on line %d
bool(false)
var_dump(imagecreatefromgif(__DIR__ . '/bug75571.gif'));
?>
--EXPECTF--
-Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d
+Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d
bool(false)
--EXPECTF--
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: JPEG datastream contains no image in %s on line %d
-Warning: imagecreatefromjpeg(): '%s' is not a valid JPEG file in %s on line %d
+Warning: imagecreatefromjpeg(): "%s" is not a valid JPEG file in %s on line %d
--EXPECTF--
Warning: imagecreatefromxbm(): Invalid XBM in %s on line %d
-Warning: imagecreatefromxbm(): '%s' is not a valid XBM file in %s on line %d
+Warning: imagecreatefromxbm(): "%s" is not a valid XBM file in %s on line %d
bool(false)
--CLEAN--
<?php
$im = imagecreate(5,5);
$c = imagecolorclosest($im, 255,0,255);
-print_r(imagecolorsforindex($im, $c));
+try {
+ imagecolorsforindex($im, $c);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
imagedestroy($im);
$im = imagecreate(5,5);
$im = imagecreate(5,5);
$c = imagecolorclosestalpha($im, 255,0,255,100);
-print_r(imagecolorsforindex($im, $c));
+try {
+ imagecolorsforindex($im, $c);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
imagedestroy($im);
$im = imagecreate(5,5);
$c = imagecolorclosestalpha($im, 255,0,0,1);
print_r(imagecolorsforindex($im, $c));
-
$im = imagecreate(5,5);
for ($i=0; $i<256; $i++) {
if ($i == 246) {
$c = imagecolorclosestalpha($im, 255,10,10,1);
print_r(imagecolorsforindex($im, $c));
-
?>
---EXPECTF--
+--EXPECT--
FF00FF
-
-Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d
+imagecolorsforindex(): Argument #2 ($index) is out of range
Array
(
[red] => 255
[alpha] => 0
)
64FF00FF
-
-Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d
+imagecolorsforindex(): Argument #2 ($index) is out of range
Array
(
[red] => 255
$im = imagecreatetruecolor(5,5);
$im2 = imagecreate(5,5);
-imagecolormatch($im, $im2);
+try {
+ imagecolormatch($im, $im2);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
echo "ok\n";
imagedestroy($im);
?>
---EXPECTF--
-Warning: imagecolormatch(): Image2 must have at least one color in %s on line %d
+--EXPECT--
+imagecolormatch(): Argument #2 ($im2) must have at least one color
ok
imagecreatefromgd(__DIR__ . '/crafted.gd2');
?>
--EXPECTF--
-Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on line %d
+Warning: imagecreatefromgd(): "%scrafted.gd2" is not a valid GD file in %s on line %d
//empty string
-$im = imagecreatefromstring('');
+try {
+ imagecreatefromstring('');
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
//random string > 12
$im = imagecreatefromstring(' asdf jklp foo');
?>
--EXPECTF--
createfromstring truecolor png: ok
createfromstring palette png: ok
-
-Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d
+imagecreatefromstring(): Argument #1 ($image) cannot be empty
Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d
Warning: imagecreatefromwbmp(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %s on line %d
-Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d
+Warning: imagecreatefromwbmp(): "%s" is not a valid WBMP file in %s on line %d
--EXPECTF--
gd warning: Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
-Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d
+Warning: imagecreatefromwbmp(): "%s_tmp.wbmp" is not a valid WBMP file in %s on line %d
$background_color = imagecolorallocate($ima, 0, 0, 0);
$imb = imagecreate(110, 20);
$background_color = imagecolorallocate($imb, 0, 0, 100);
-var_dump(imagecolormatch($ima, $imb));
+
+try {
+ imagecolormatch($ima, $imb);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
?>
---EXPECTF--
-Warning: imagecolormatch(): Image1 must be TrueColor in %s on line %d
-bool(false)
+--EXPECT--
+imagecolormatch(): Argument #1 ($im1) must be TrueColor
$background_color = imagecolorallocate($ima, 0, 0, 0);
$imb = imagecreatetruecolor(110, 20);
$background_color = imagecolorallocate($imb, 0, 0, 100);
-var_dump(imagecolormatch($ima, $imb));
+
+try {
+ imagecolormatch($ima, $imb);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
?>
---EXPECTF--
-Warning: imagecolormatch(): Image2 must be Palette in %s on line %d
-bool(false)
+--EXPECT--
+imagecolormatch(): Argument #2 ($im2) must be Palette
$background_color = imagecolorallocate($ima, 0, 0, 0);
$imb = imagecreate(100, 20);
$background_color = imagecolorallocate($imb, 0, 0, 100);
-var_dump(imagecolormatch($ima, $imb));
+
+try {
+ imagecolormatch($ima, $imb);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
?>
---EXPECTF--
-Warning: imagecolormatch(): Image1 and Image2 must be the same size in %s on line %d
-bool(false)
+--EXPECT--
+imagecolormatch(): Argument #2 ($im2) must be the same size as argument #1 ($im1)
Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d
-Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d
+Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d
bool(false)
gd-png: fatal libpng error: Read Error: truncated data
gd-png error: setjmp returns error condition 1
-Warning: imagecreatefrompng(): '%slibgd00086.png' is not a valid PNG file in %s on line %d
+Warning: imagecreatefrompng(): "%slibgd00086.png" is not a valid PNG file in %s on line %d
bool(false)
var_dump($im);
?>
--EXPECTF--
-Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.php on line %d
+Warning: imagecreatefromxbm(): "%slibgd00094私はガラスを食べられます.xbm" is not a valid XBM file in %slibgd00094-mb.php on line %d
bool(false)
var_dump($im);
?>
--EXPECTF--
-Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d
+Warning: imagecreatefromxbm(): "%slibgd00094.xbm" is not a valid XBM file in %slibgd00094.php on line %d
bool(false)
Warning: imagecreatefromgd(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in %slibgd00101.php on line %d
-Warning: imagecreatefromgd(): '%slibgd00101.gd' is not a valid GD file in %slibgd00101.php on line %d
+Warning: imagecreatefromgd(): "%slibgd00101.gd" is not a valid GD file in %slibgd00101.php on line %d
bool(false)