Skip to content

Commit 9099dbd

Browse files
committed
Use RETURN_THROWS() after zend_type_error()
1 parent 12ce73a commit 9099dbd

File tree

13 files changed

+45
-45
lines changed

13 files changed

+45
-45
lines changed

ext/bz2/bz2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static PHP_FUNCTION(bzopen)
380380

381381
if (CHECK_ZVAL_NULL_PATH(file)) {
382382
zend_type_error("filename must not contain null bytes");
383-
return;
383+
RETURN_THROWS();
384384
}
385385

386386
stream = php_stream_bz2open(NULL, Z_STRVAL_P(file), mode, REPORT_ERRORS, NULL);

ext/gd/gd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,7 +3902,7 @@ PHP_FUNCTION(imageaffine)
39023902
break;
39033903
default:
39043904
zend_type_error("Invalid type for element %i", i);
3905-
return;
3905+
RETURN_THROWS();
39063906
}
39073907
}
39083908
}
@@ -3976,7 +3976,7 @@ PHP_FUNCTION(imageaffinematrixget)
39763976
double x, y;
39773977
if (!options || Z_TYPE_P(options) != IS_ARRAY) {
39783978
zend_type_error("Array expected as options when using translate or scale");
3979-
return;
3979+
RETURN_THROWS();
39803980
}
39813981

39823982
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "x", sizeof("x") - 1)) != NULL) {
@@ -4008,7 +4008,7 @@ PHP_FUNCTION(imageaffinematrixget)
40084008

40094009
if (!options) {
40104010
zend_type_error("Number is expected as option when using rotate or shear");
4011-
return;
4011+
RETURN_THROWS();
40124012
}
40134013

40144014
angle = zval_get_double(options);
@@ -4074,7 +4074,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
40744074
break;
40754075
default:
40764076
zend_type_error("Matrix 1 contains invalid type for element %i", i);
4077-
return;
4077+
RETURN_THROWS();
40784078
}
40794079
}
40804080

@@ -4091,7 +4091,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
40914091
break;
40924092
default:
40934093
zend_type_error("Matrix 2 contains invalid type for element %i", i);
4094-
return;
4094+
RETURN_THROWS();
40954095
}
40964096
}
40974097
}
@@ -4285,7 +4285,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
42854285
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
42864286
if (CHECK_ZVAL_NULL_PATH(to_zval)) {
42874287
zend_type_error("Invalid 2nd parameter, filename must not contain null bytes");
4288-
return;
4288+
RETURN_THROWS();
42894289
}
42904290

42914291
stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);

ext/hash/hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,12 @@ PHP_FUNCTION(hash_equals)
873873
/* We only allow comparing string to prevent unexpected results. */
874874
if (Z_TYPE_P(known_zval) != IS_STRING) {
875875
zend_type_error("Expected known_string to be a string, %s given", zend_zval_type_name(known_zval));
876-
return;
876+
RETURN_THROWS();
877877
}
878878

879879
if (Z_TYPE_P(user_zval) != IS_STRING) {
880880
zend_type_error("Expected user_string to be a string, %s given", zend_zval_type_name(user_zval));
881-
return;
881+
RETURN_THROWS();
882882
}
883883

884884
if (Z_STRLEN_P(known_zval) != Z_STRLEN_P(user_zval)) {

ext/pcre/php_pcre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,7 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter)
22592259
} else {
22602260
if (Z_TYPE_P(regex) != IS_ARRAY) {
22612261
zend_type_error("Parameter mismatch, pattern is a string while replacement is an array");
2262-
return;
2262+
RETURN_THROWS();
22632263
}
22642264
}
22652265

ext/reflection/php_reflection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6260,7 +6260,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
62606260
item = zend_symtable_find(ht, Z_STR_P(key));
62616261
} else {
62626262
zend_type_error("Key must be array or string");
6263-
return;
6263+
RETURN_THROWS();
62646264
}
62656265

62666266
if (!item) {

ext/spl/php_spl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ PHP_FUNCTION(class_parents)
9494

9595
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
9696
zend_type_error("object or string expected");
97-
return;
97+
RETURN_THROWS();
9898
}
9999

100100
if (Z_TYPE_P(obj) == IS_STRING) {
@@ -127,7 +127,7 @@ PHP_FUNCTION(class_implements)
127127
}
128128
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
129129
zend_type_error("object or string expected");
130-
return;
130+
RETURN_THROWS();
131131
}
132132

133133
if (Z_TYPE_P(obj) == IS_STRING) {
@@ -156,7 +156,7 @@ PHP_FUNCTION(class_uses)
156156
}
157157
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
158158
zend_type_error("object or string expected");
159-
return;
159+
RETURN_THROWS();
160160
}
161161

162162
if (Z_TYPE_P(obj) == IS_STRING) {

ext/standard/array.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ PHP_FUNCTION(min)
12581258

12591259
if (Z_TYPE(args[0]) != IS_ARRAY) {
12601260
zend_type_error("When only one parameter is given, it must be an array");
1261-
return;
1261+
RETURN_THROWS();
12621262
} else {
12631263
if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 0)) != NULL) {
12641264
ZVAL_COPY_DEREF(return_value, result);
@@ -1305,7 +1305,7 @@ PHP_FUNCTION(max)
13051305

13061306
if (Z_TYPE(args[0]) != IS_ARRAY) {
13071307
zend_type_error("When only one parameter is given, it must be an array");
1308-
return;
1308+
RETURN_THROWS();
13091309
} else {
13101310
if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 1)) != NULL) {
13111311
ZVAL_COPY_DEREF(return_value, result);
@@ -3785,7 +3785,7 @@ static zend_always_inline void php_array_replace_wrapper(INTERNAL_FUNCTION_PARAM
37853785

37863786
if (Z_TYPE_P(arg) != IS_ARRAY) {
37873787
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(arg));
3788-
return;
3788+
RETURN_THROWS();
37893789
}
37903790
}
37913791

@@ -3829,7 +3829,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
38293829

38303830
if (Z_TYPE_P(arg) != IS_ARRAY) {
38313831
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(arg));
3832-
return;
3832+
RETURN_THROWS();
38333833
}
38343834
count += zend_hash_num_elements(Z_ARRVAL_P(arg));
38353835
}
@@ -4721,7 +4721,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
47214721
for (i = 0; i < argc; i++) {
47224722
if (Z_TYPE(args[i]) != IS_ARRAY) {
47234723
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
4724-
return;
4724+
RETURN_THROWS();
47254725
}
47264726
}
47274727

@@ -5126,7 +5126,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
51265126
for (i = 0; i < argc; i++) {
51275127
if (Z_TYPE(args[i]) != IS_ARRAY) {
51285128
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
5129-
return;
5129+
RETURN_THROWS();
51305130
}
51315131
}
51325132

@@ -5468,15 +5468,15 @@ PHP_FUNCTION(array_diff)
54685468

54695469
if (Z_TYPE(args[0]) != IS_ARRAY) {
54705470
zend_type_error("Expected parameter 1 to be an array, %s given", zend_zval_type_name(&args[0]));
5471-
return;
5471+
RETURN_THROWS();
54725472
}
54735473

54745474
num = zend_hash_num_elements(Z_ARRVAL(args[0]));
54755475
if (num == 0) {
54765476
for (i = 1; i < argc; i++) {
54775477
if (Z_TYPE(args[i]) != IS_ARRAY) {
54785478
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
5479-
return;
5479+
RETURN_THROWS();
54805480
}
54815481
}
54825482
RETURN_EMPTY_ARRAY();
@@ -5493,7 +5493,7 @@ PHP_FUNCTION(array_diff)
54935493
for (i = 1; i < argc; i++) {
54945494
if (Z_TYPE(args[i]) != IS_ARRAY) {
54955495
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
5496-
return;
5496+
RETURN_THROWS();
54975497
}
54985498
}
54995499
RETURN_EMPTY_ARRAY();
@@ -5504,7 +5504,7 @@ PHP_FUNCTION(array_diff)
55045504
for (i = 1; i < argc; i++) {
55055505
if (Z_TYPE(args[i]) != IS_ARRAY) {
55065506
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
5507-
return;
5507+
RETURN_THROWS();
55085508
}
55095509
if (!found) {
55105510
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[i]), value) {
@@ -5534,7 +5534,7 @@ PHP_FUNCTION(array_diff)
55345534
for (i = 1; i < argc; i++) {
55355535
if (Z_TYPE(args[i]) != IS_ARRAY) {
55365536
zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
5537-
return;
5537+
RETURN_THROWS();
55385538
}
55395539
num += zend_hash_num_elements(Z_ARRVAL(args[i]));
55405540
}
@@ -6186,7 +6186,7 @@ PHP_FUNCTION(array_map)
61866186

61876187
if (Z_TYPE(arrays[0]) != IS_ARRAY) {
61886188
zend_type_error("Expected parameter 2 to be an array, %s given", zend_zval_type_name(&arrays[0]));
6189-
return;
6189+
RETURN_THROWS();
61906190
}
61916191
maxlen = zend_hash_num_elements(Z_ARRVAL(arrays[0]));
61926192

@@ -6228,7 +6228,7 @@ PHP_FUNCTION(array_map)
62286228
if (Z_TYPE(arrays[i]) != IS_ARRAY) {
62296229
zend_type_error("Expected parameter %d to be an array, %s given", i + 2, zend_zval_type_name(&arrays[i]));
62306230
efree(array_pos);
6231-
return;
6231+
RETURN_THROWS();
62326232
}
62336233
if (zend_hash_num_elements(Z_ARRVAL(arrays[i])) > maxlen) {
62346234
maxlen = zend_hash_num_elements(Z_ARRVAL(arrays[i]));

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3203,7 +3203,7 @@ PHP_FUNCTION(register_tick_function)
32033203
efree(tick_fe.arguments);
32043204
zend_type_error("Invalid tick callback '%s' passed", ZSTR_VAL(function_name));
32053205
zend_string_release_ex(function_name, 0);
3206-
return;
3206+
RETURN_THROWS();
32073207
} else if (function_name) {
32083208
zend_string_release_ex(function_name, 0);
32093209
}

ext/standard/dir.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ PHP_FUNCTION(closedir)
260260

261261
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
262262
zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
263-
return;
263+
RETURN_THROWS();
264264
}
265265

266266
res = dirp->res;
@@ -374,7 +374,7 @@ PHP_FUNCTION(rewinddir)
374374

375375
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
376376
zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
377-
return;
377+
RETURN_THROWS();
378378
}
379379

380380
php_stream_rewinddir(dirp);
@@ -393,7 +393,7 @@ PHP_NAMED_FUNCTION(php_if_readdir)
393393

394394
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
395395
zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
396-
return;
396+
RETURN_THROWS();
397397
}
398398

399399
if (php_stream_readdir(dirp, &entry)) {

ext/standard/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ PHP_FUNCTION(escapeshellcmd)
485485
if (command_len) {
486486
if (command_len != strlen(command)) {
487487
zend_type_error("Input string contains NULL bytes");
488-
return;
488+
RETURN_THROWS();
489489
}
490490
RETVAL_STR(php_escape_shell_cmd(command));
491491
} else {
@@ -507,7 +507,7 @@ PHP_FUNCTION(escapeshellarg)
507507

508508
if (argument_len != strlen(argument)) {
509509
zend_type_error("Input string contains NULL bytes");
510-
return;
510+
RETURN_THROWS();
511511
}
512512

513513
RETVAL_STR(php_escape_shell_arg(argument));

0 commit comments

Comments
 (0)