nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
if (nelem < 6) {
- php_error_docref(NULL, E_WARNING, "You must have at least 3 points in your array");
- RETURN_FALSE;
+ zend_throw_error(NULL, "You must have at least 3 points in your array");
+ return;
}
+
if (npoints <= 0) {
- php_error_docref(NULL, E_WARNING, "You must give a positive number of points");
- RETURN_FALSE;
+ zend_throw_error(NULL, "You must give a positive number of points");
+ return;
}
+
if (nelem < npoints * 2) {
- php_error_docref(NULL, E_WARNING, "Trying to use %d points in array with only %d points", npoints, nelem/2);
- RETURN_FALSE;
+ zend_throw_error(NULL, "Trying to use %d points in array with only %d points", npoints, nelem/2);
+ return;
}
points = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0);
?>
--FILE--
<?php
+require __DIR__ . '/func.inc';
+
$im = imagecreate(100, 100);
$black = imagecolorallocate($im, 0, 0, 0);
-if (imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false";
+
+trycatch_dump(
+ fn() => imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)
+);
+
imagedestroy($im);
?>
---EXPECTF--
-Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d
+--EXPECT--
+!! [Error] You must give a positive number of points
?>
--FILE--
<?php
+require __DIR__ . '/func.inc';
+
$im = imagecreate(100, 100);
$black = imagecolorallocate($im, 0, 0, 0);
-if (imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false";
+
+trycatch_dump(
+ fn() => imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)
+);
+
imagedestroy($im);
?>
---EXPECTF--
-Warning: imagepolygon(): You must give a positive number of points in %s on line %d
+--EXPECT--
+!! [Error] You must give a positive number of points