}
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
- php_error_docref(NULL, E_WARNING, "Affine array must have six elements");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Affine array must have six elements");
+ return;
}
for (i = 0; i < nelems; i++) {
affine[i] = zval_get_double(zval_affine_elem);
break;
default:
- php_error_docref(NULL, E_WARNING, "Invalid type for element %i", i);
- RETURN_FALSE;
+ zend_type_error("Invalid type for element %i", i);
+ return;
}
}
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") - 1)) != NULL) {
rect.x = zval_get_long(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing x position");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Clip array is missing x position");
+ return;
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
rect.y = zval_get_long(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing y position");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Clip array is missing y position");
+ return;
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
rect.width = zval_get_long(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing width");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Clip array is missing width");
+ return;
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
rect.height = zval_get_long(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing height");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Clip array is missing height");
+ return;
}
pRect = ▭
} else {
case GD_AFFINE_SCALE: {
double x, y;
if (!options || Z_TYPE_P(options) != IS_ARRAY) {
- php_error_docref(NULL, E_WARNING, "Array expected as options");
- RETURN_FALSE;
+ zend_type_error("Array expected as options when using translate or scale");
+ return;
}
+
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "x", sizeof("x") - 1)) != NULL) {
x = zval_get_double(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing x position");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Options array is missing x position");
+ return;
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "y", sizeof("y") - 1)) != NULL) {
y = zval_get_double(tmp);
} else {
- php_error_docref(NULL, E_WARNING, "Missing y position");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Options array is missing y position");
+ return;
}
if (type == GD_AFFINE_TRANSLATE) {
double angle;
if (!options) {
- php_error_docref(NULL, E_WARNING, "Number is expected as option");
- RETURN_FALSE;
+ zend_type_error("Number is expected as option when using rotate or shear");
+ return;
}
angle = zval_get_double(options);
}
default:
- php_error_docref(NULL, E_WARNING, "Invalid type for element " ZEND_LONG_FMT, type);
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid type for element " ZEND_LONG_FMT, type);
+ return;
}
if (res == GD_FALSE) {
}
if (((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m1))) != 6) || (nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m2))) != 6) {
- php_error_docref(NULL, E_WARNING, "Affine arrays must have six elements");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Affine arrays must have six elements");
+ return;
}
for (i = 0; i < 6; i++) {
m1[i] = zval_get_double(tmp);
break;
default:
- php_error_docref(NULL, E_WARNING, "Invalid type for element %i", i);
- RETURN_FALSE;
+ zend_type_error("Matrix 1 contains invalid type for element %i", i);
+ return;
}
}
+
if ((tmp = zend_hash_index_find(Z_ARRVAL_P(z_m2), i)) != NULL) {
switch (Z_TYPE_P(tmp)) {
case IS_LONG:
m2[i] = zval_get_double(tmp);
break;
default:
- php_error_docref(NULL, E_WARNING, "Invalid type for element %i", i);
- RETURN_FALSE;
+ zend_type_error("Matrix 2 contains invalid type for element %i", i);
+ return;
}
}
}
?>
--FILE--
<?php
+require __DIR__ . '/func.inc';
+
for($i=0;$i<7;$i++) {
- imageaffinematrixget($i);
+ trycatch_dump(
+ fn() => imageaffinematrixget($i)
+ );
}
?>
---EXPECTF--
-Warning: imageaffinematrixget(): Array expected as options in %s on line %d
-
-Warning: imageaffinematrixget(): Array expected as options in %s on line %d
-
-Warning: imageaffinematrixget(): Number is expected as option in %s on line %d
-
-Warning: imageaffinematrixget(): Number is expected as option in %s on line %d
-
-Warning: imageaffinematrixget(): Number is expected as option in %s on line %d
-
-Warning: imageaffinematrixget(): Invalid type for element 5 in %s on line %d
-
-Warning: imageaffinematrixget(): Invalid type for element 6 in %s on line %d
+--EXPECT--
+!! [TypeError] Array expected as options when using translate or scale
+!! [TypeError] Array expected as options when using translate or scale
+!! [TypeError] Number is expected as option when using rotate or shear
+!! [TypeError] Number is expected as option when using rotate or shear
+!! [TypeError] Number is expected as option when using rotate or shear
+!! [Error] Invalid type for element 5
+!! [Error] Invalid type for element 6