Skip to content

Commit e7c4d54

Browse files
committed
Use new helper function for "cannot be empty" ValueErrors
1 parent 96d572a commit e7c4d54

40 files changed

+96
-96
lines changed

ext/bz2/bz2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ PHP_FUNCTION(bzopen)
349349
/* If it's not a resource its a string containing the filename to open */
350350
if (Z_TYPE_P(file) == IS_STRING) {
351351
if (Z_STRLEN_P(file) == 0) {
352-
zend_argument_value_error(1, "cannot be empty");
352+
zend_argument_cannot_be_empty_error(1);
353353
RETURN_THROWS();
354354
}
355355

ext/dba/dba.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,15 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
547547
}
548548

549549
if (ZSTR_LEN(path) == 0) {
550-
zend_argument_value_error(1, "cannot be empty");
550+
zend_argument_cannot_be_empty_error(1);
551551
RETURN_THROWS();
552552
}
553553
if (ZSTR_LEN(mode) == 0) {
554-
zend_argument_value_error(2, "cannot be empty");
554+
zend_argument_cannot_be_empty_error(2);
555555
RETURN_THROWS();
556556
}
557557
if (handler_str && ZSTR_LEN(handler_str) == 0) {
558-
zend_argument_value_error(3, "cannot be empty");
558+
zend_argument_cannot_be_empty_error(3);
559559
RETURN_THROWS();
560560
}
561561
// TODO Check Value for permission
@@ -640,7 +640,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
640640
// bool is_file_lock = false;
641641

642642
if (ZSTR_LEN(mode) == 0) {
643-
zend_argument_value_error(2, "cannot be empty");
643+
zend_argument_cannot_be_empty_error(2);
644644
efree(resource_key);
645645
RETURN_THROWS();
646646
}

ext/dom/domimplementation.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PHP_METHOD(DOMImplementation, createDocumentType)
6464
}
6565

6666
if (name_len == 0) {
67-
zend_argument_value_error(1, "cannot be empty");
67+
zend_argument_cannot_be_empty_error(1);
6868
RETURN_THROWS();
6969
}
7070

ext/dom/element.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ PHP_METHOD(DOMElement, setAttribute)
411411
}
412412

413413
if (name_len == 0) {
414-
zend_argument_value_error(1, "cannot be empty");
414+
zend_argument_cannot_be_empty_error(1);
415415
RETURN_THROWS();
416416
}
417417

@@ -903,7 +903,7 @@ PHP_METHOD(DOMElement, getAttributeNS)
903903
static void dom_set_attribute_ns_legacy(dom_object *intern, xmlNodePtr elemp, char *uri, size_t uri_len, char *name, size_t name_len, const char *value)
904904
{
905905
if (name_len == 0) {
906-
zend_argument_value_error(2, "cannot be empty");
906+
zend_argument_cannot_be_empty_error(2);
907907
return;
908908
}
909909

ext/enchant/enchant.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ PHP_FUNCTION(enchant_broker_request_dict)
447447
PHP_ENCHANT_GET_BROKER;
448448

449449
if (taglen == 0) {
450-
zend_argument_value_error(2, "cannot be empty");
450+
zend_argument_cannot_be_empty_error(2);
451451
RETURN_THROWS();
452452
}
453453

ext/exif/exif.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4550,7 +4550,7 @@ PHP_FUNCTION(exif_read_data)
45504550
}
45514551

45524552
if (!Z_STRLEN_P(stream)) {
4553-
zend_argument_value_error(1, "cannot be empty");
4553+
zend_argument_cannot_be_empty_error(1);
45544554
RETURN_THROWS();
45554555
}
45564556

@@ -4727,7 +4727,7 @@ PHP_FUNCTION(exif_thumbnail)
47274727
}
47284728

47294729
if (!Z_STRLEN_P(stream)) {
4730-
zend_argument_value_error(1, "cannot be empty");
4730+
zend_argument_cannot_be_empty_error(1);
47314731
RETURN_THROWS();
47324732
}
47334733

ext/fileinfo/fileinfo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
374374
php_stream_statbuf ssb;
375375

376376
if (buffer == NULL || buffer_len == 0) {
377-
zend_argument_value_error(1, "cannot be empty");
377+
zend_argument_cannot_be_empty_error(1);
378378
goto clean;
379379
}
380380
if (CHECK_NULL_PATH(buffer, buffer_len)) {

ext/gd/gd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ PHP_FUNCTION(imagesetstyle)
646646

647647
num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles));
648648
if (num_styles == 0) {
649-
zend_argument_value_error(2, "cannot be empty");
649+
zend_argument_cannot_be_empty_error(2);
650650
RETURN_THROWS();
651651
}
652652

ext/gettext/gettext.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ZEND_GET_MODULE(php_gettext)
5555
zend_argument_value_error(_arg_num, "is too long"); \
5656
RETURN_THROWS(); \
5757
} else if (domain_len == 0) { \
58-
zend_argument_value_error(_arg_num, "cannot be empty"); \
58+
zend_argument_cannot_be_empty_error(_arg_num); \
5959
RETURN_THROWS(); \
6060
}
6161

@@ -191,7 +191,7 @@ PHP_FUNCTION(bindtextdomain)
191191
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
192192

193193
if (!ZSTR_LEN(domain)) {
194-
zend_argument_value_error(1, "cannot be empty");
194+
zend_argument_cannot_be_empty_error(1);
195195
RETURN_THROWS();
196196
}
197197

@@ -313,7 +313,7 @@ PHP_FUNCTION(bind_textdomain_codeset)
313313
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
314314

315315
if (!ZSTR_LEN(domain)) {
316-
zend_argument_value_error(1, "cannot be empty");
316+
zend_argument_cannot_be_empty_error(1);
317317
RETURN_THROWS();
318318
}
319319

ext/hash/hash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ PHP_FUNCTION(hash_hkdf)
914914
}
915915

916916
if (ZSTR_LEN(ikm) == 0) {
917-
zend_argument_value_error(2, "cannot be empty");
917+
zend_argument_cannot_be_empty_error(2);
918918
RETURN_THROWS();
919919
}
920920

ext/intl/idn/idn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
125125
ZEND_PARSE_PARAMETERS_END();
126126

127127
if (ZSTR_LEN(domain) == 0) {
128-
zend_argument_value_error(1, "cannot be empty");
128+
zend_argument_cannot_be_empty_error(1);
129129
RETURN_THROWS();
130130
}
131131
if (ZSTR_LEN(domain) > INT32_MAX - 1) {

ext/intl/resourcebundle/resourcebundle_class.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static zval *resource_bundle_array_fetch(
186186
if (offset_str) {
187187
if (UNEXPECTED(ZSTR_LEN(offset_str) == 0)) {
188188
if (offset_arg_num) {
189-
zend_argument_value_error(offset_arg_num, "cannot be empty");
189+
zend_argument_cannot_be_empty_error(offset_arg_num);
190190
} else {
191191
zend_value_error("Offset cannot be empty");
192192
}

ext/ldap/ldap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
15011501

15021502
nlinks = zend_hash_num_elements(Z_ARRVAL_P(link));
15031503
if (nlinks == 0) {
1504-
zend_argument_value_error(1, "cannot be empty");
1504+
zend_argument_cannot_be_empty_error(1);
15051505
ret = 0;
15061506
goto cleanup;
15071507
}

ext/mysqli/mysqli_api.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
139139
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
140140

141141
if (!types_len) {
142-
zend_argument_value_error(ERROR_ARG_POS(2), "cannot be empty");
142+
zend_argument_cannot_be_empty_error(ERROR_ARG_POS(2));
143143
RETURN_THROWS();
144144
}
145145

ext/mysqli/mysqli_nonapi.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ PHP_FUNCTION(mysqli_query)
572572
}
573573

574574
if (!query_len) {
575-
zend_argument_value_error(ERROR_ARG_POS(2), "cannot be empty");
575+
zend_argument_cannot_be_empty_error(ERROR_ARG_POS(2));
576576
RETURN_THROWS();
577577
}
578578
if ((resultmode & ~MYSQLI_ASYNC) != MYSQLI_USE_RESULT &&
@@ -1013,7 +1013,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
10131013
RETURN_THROWS();
10141014
}
10151015
if (name && !name_len) {
1016-
zend_argument_value_error(ERROR_ARG_POS(3), "cannot be empty");
1016+
zend_argument_cannot_be_empty_error(ERROR_ARG_POS(3));
10171017
RETURN_THROWS();
10181018
}
10191019

@@ -1037,7 +1037,7 @@ PHP_FUNCTION(mysqli_savepoint)
10371037
}
10381038
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
10391039
if (name_len == 0) {
1040-
zend_argument_value_error(ERROR_ARG_POS(2), "cannot be empty");
1040+
zend_argument_cannot_be_empty_error(ERROR_ARG_POS(2));
10411041
RETURN_THROWS();
10421042
}
10431043

@@ -1061,7 +1061,7 @@ PHP_FUNCTION(mysqli_release_savepoint)
10611061
}
10621062
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
10631063
if (name_len == 0) {
1064-
zend_argument_value_error(ERROR_ARG_POS(2), "cannot be empty");
1064+
zend_argument_cannot_be_empty_error(ERROR_ARG_POS(2));
10651065
RETURN_THROWS();
10661066
}
10671067
if (FAIL == mysqlnd_release_savepoint(mysql->mysql, name)) {

ext/openssl/openssl.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -7243,7 +7243,7 @@ PHP_FUNCTION(openssl_seal)
72437243
pubkeysht = Z_ARRVAL_P(pubkeys);
72447244
nkeys = pubkeysht ? zend_hash_num_elements(pubkeysht) : 0;
72457245
if (!nkeys) {
7246-
zend_argument_value_error(4, "cannot be empty");
7246+
zend_argument_cannot_be_empty_error(4);
72477247
RETURN_THROWS();
72487248
}
72497249

@@ -8017,7 +8017,7 @@ PHP_FUNCTION(openssl_decrypt)
80178017
}
80188018

80198019
if (!method_len) {
8020-
zend_argument_value_error(2, "cannot be empty");
8020+
zend_argument_cannot_be_empty_error(2);
80218021
RETURN_THROWS();
80228022
}
80238023

@@ -8059,7 +8059,7 @@ PHP_FUNCTION(openssl_cipher_iv_length)
80598059
}
80608060

80618061
if (ZSTR_LEN(method) == 0) {
8062-
zend_argument_value_error(1, "cannot be empty");
8062+
zend_argument_cannot_be_empty_error(1);
80638063
RETURN_THROWS();
80648064
}
80658065

@@ -8088,7 +8088,7 @@ PHP_FUNCTION(openssl_cipher_key_length)
80888088
}
80898089

80908090
if (ZSTR_LEN(method) == 0) {
8091-
zend_argument_value_error(1, "cannot be empty");
8091+
zend_argument_cannot_be_empty_error(1);
80928092
RETURN_THROWS();
80938093
}
80948094

ext/pcntl/pcntl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ static bool php_pcntl_set_user_signal_infos(
860860
bool allow_empty_signal_array
861861
) {
862862
if (!allow_empty_signal_array && zend_hash_num_elements(user_signals) == 0) {
863-
zend_argument_value_error(arg_num, "cannot be empty");
863+
zend_argument_cannot_be_empty_error(arg_num);
864864
return false;
865865
}
866866

ext/pdo/pdo_dbh.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ PHP_METHOD(PDO, prepare)
563563
PDO_CONSTRUCT_CHECK;
564564

565565
if (ZSTR_LEN(statement) == 0) {
566-
zend_argument_value_error(1, "cannot be empty");
566+
zend_argument_cannot_be_empty_error(1);
567567
RETURN_THROWS();
568568
}
569569

@@ -1030,7 +1030,7 @@ PHP_METHOD(PDO, exec)
10301030
ZEND_PARSE_PARAMETERS_END();
10311031

10321032
if (ZSTR_LEN(statement) == 0) {
1033-
zend_argument_value_error(1, "cannot be empty");
1033+
zend_argument_cannot_be_empty_error(1);
10341034
RETURN_THROWS();
10351035
}
10361036

@@ -1166,7 +1166,7 @@ PHP_METHOD(PDO, query)
11661166
PDO_CONSTRUCT_CHECK;
11671167

11681168
if (ZSTR_LEN(statement) == 0) {
1169-
zend_argument_value_error(1, "cannot be empty");
1169+
zend_argument_cannot_be_empty_error(1);
11701170
RETURN_THROWS();
11711171
}
11721172

ext/pdo/pdo_stmt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static void register_bound_param(INTERNAL_FUNCTION_PARAMETERS, int is_param) /*
14231423

14241424
if (param.name) {
14251425
if (ZSTR_LEN(param.name) == 0) {
1426-
zend_argument_value_error(1, "cannot be empty");
1426+
zend_argument_cannot_be_empty_error(1);
14271427
RETURN_THROWS();
14281428
}
14291429
param.paramno = -1;
@@ -1471,7 +1471,7 @@ PHP_METHOD(PDOStatement, bindValue)
14711471

14721472
if (param.name) {
14731473
if (ZSTR_LEN(param.name) == 0) {
1474-
zend_argument_value_error(1, "cannot be empty");
1474+
zend_argument_cannot_be_empty_error(1);
14751475
RETURN_THROWS();
14761476
}
14771477
param.paramno = -1;

ext/pdo_pgsql/pgsql_driver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ void pgsqlCopyFromArray_internal(INTERNAL_FUNCTION_PARAMETERS)
627627
}
628628

629629
if (!zend_hash_num_elements(Z_ARRVAL_P(pg_rows))) {
630-
zend_argument_value_error(2, "cannot be empty");
630+
zend_argument_cannot_be_empty_error(2);
631631
RETURN_THROWS();
632632
}
633633

ext/pdo_sqlite/pdo_sqlite.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ PHP_METHOD(Pdo_Sqlite, loadExtension)
8282
}
8383

8484
if (extension_len == 0) {
85-
zend_argument_value_error(1, "cannot be empty");
85+
zend_argument_cannot_be_empty_error(1);
8686
RETURN_THROWS();
8787
}
8888

ext/pgsql/pgsql.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -4613,7 +4613,7 @@ PHP_FUNCTION(pg_meta_data)
46134613

46144614
/* php_pgsql_meta_data() asserts that table_name is not empty */
46154615
if (ZSTR_LEN(table_name) == 0) {
4616-
zend_argument_value_error(2, "cannot be empty");
4616+
zend_argument_cannot_be_empty_error(2);
46174617
RETURN_THROWS();
46184618
}
46194619

@@ -5405,7 +5405,7 @@ PHP_FUNCTION(pg_convert)
54055405
ZEND_PARSE_PARAMETERS_END();
54065406

54075407
if (ZSTR_LEN(table_name) == 0) {
5408-
zend_argument_value_error(2, "cannot be empty");
5408+
zend_argument_cannot_be_empty_error(2);
54095409
RETURN_THROWS();
54105410
}
54115411

@@ -5618,7 +5618,7 @@ PHP_FUNCTION(pg_insert)
56185618
ZEND_PARSE_PARAMETERS_END();
56195619

56205620
if (ZSTR_LEN(table) == 0) {
5621-
zend_argument_value_error(2, "cannot be empty");
5621+
zend_argument_cannot_be_empty_error(2);
56225622
RETURN_THROWS();
56235623
}
56245624

@@ -5840,7 +5840,7 @@ PHP_FUNCTION(pg_update)
58405840
ZEND_PARSE_PARAMETERS_END();
58415841

58425842
if (ZSTR_LEN(table) == 0) {
5843-
zend_argument_value_error(2, "cannot be empty");
5843+
zend_argument_cannot_be_empty_error(2);
58445844
RETURN_THROWS();
58455845
}
58465846

@@ -5939,7 +5939,7 @@ PHP_FUNCTION(pg_delete)
59395939
ZEND_PARSE_PARAMETERS_END();
59405940

59415941
if (ZSTR_LEN(table) == 0) {
5942-
zend_argument_value_error(2, "cannot be empty");
5942+
zend_argument_cannot_be_empty_error(2);
59435943
RETURN_THROWS();
59445944
}
59455945

@@ -6095,7 +6095,7 @@ PHP_FUNCTION(pg_select)
60956095
ZEND_PARSE_PARAMETERS_END();
60966096

60976097
if (ZSTR_LEN(table) == 0) {
6098-
zend_argument_value_error(2, "cannot be empty");
6098+
zend_argument_cannot_be_empty_error(2);
60996099
RETURN_THROWS();
61006100
}
61016101

@@ -6143,13 +6143,13 @@ PHP_FUNCTION(pg_change_password)
61436143
ZEND_PARSE_PARAMETERS_END();
61446144

61456145
if (ZSTR_LEN(user) == 0) {
6146-
zend_argument_value_error(2, "cannot be empty");
6146+
zend_argument_cannot_be_empty_error(2);
61476147
RETURN_THROWS();
61486148
}
61496149

61506150
/* it is technically possible, but better to disallow it */
61516151
if (ZSTR_LEN(passwd) == 0) {
6152-
zend_argument_value_error(3, "cannot be empty");
6152+
zend_argument_cannot_be_empty_error(3);
61536153
RETURN_THROWS();
61546154
}
61556155

0 commit comments

Comments
 (0)