Skip to content

Commit 543c280

Browse files
committed
tree-wide: Replace ZEND_WRONG_PARAM_COUNT() by its definition
This macro was hiding control flow (the return statement) and thus was particularly unhygienic.
1 parent a0afb98 commit 543c280

File tree

9 files changed

+21
-12
lines changed

9 files changed

+21
-12
lines changed

UPGRADING.INTERNALS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
2020
. The misnamed ZVAL_IS_NULL() has been removed. Use Z_ISNULL() instead.
2121
. New zend_class_entry.ce_flags2 and zend_function.fn_flags2 fields were
2222
added, given the primary flags were running out of bits.
23-
. The WRONG_PARAM_COUNT macro has been removed. Use
24-
ZEND_WRONG_PARAM_COUNT() directly instead.
23+
. The WRONG_PARAM_COUNT and ZEND_WRONG_PARAM_COUNT() macros have been
24+
removed. Call zend_wrong_param_count(); followed by RETURN_THROWS();
25+
instead.
2526

2627
========================
2728
2. Build system changes

Zend/zend_API.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ ZEND_API const char *zend_get_type_by_const(int type);
528528
#define ZEND_IS_METHOD_CALL() (EX(func)->common.scope != NULL)
529529

530530
#define ZEND_NUM_ARGS() EX_NUM_ARGS()
531-
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(); return; }
532531

533532
#ifndef ZEND_WIN32
534533
#define DLEXPORT

ext/gd/gd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3624,7 +3624,8 @@ PHP_FUNCTION(imagefilter)
36243624
};
36253625

36263626
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) {
3627-
ZEND_WRONG_PARAM_COUNT();
3627+
zend_wrong_param_count();
3628+
RETURN_THROWS();
36283629
} else if (zend_parse_parameters(2, "Ol", &tmp, gd_image_ce, &filtertype) == FAILURE) {
36293630
RETURN_THROWS();
36303631
}

ext/ldap/ldap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ PHP_FUNCTION(ldap_connect)
980980

981981
#ifdef HAVE_ORALDAP
982982
if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
983-
ZEND_WRONG_PARAM_COUNT();
983+
zend_wrong_param_count();
984+
RETURN_THROWS();
984985
}
985986

986987
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!lssl", &host, &hostlen, &port, &wallet, &walletlen, &walletpasswd, &walletpasswdlen, &authmode) != SUCCESS) {

ext/pgsql/pgsql.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,8 @@ PHP_FUNCTION(pg_fetch_assoc)
21142114
/* pg_fetch_assoc() is added from PHP 4.3.0. It should raise error, when
21152115
there is 3rd parameter */
21162116
if (ZEND_NUM_ARGS() > 2) {
2117-
ZEND_WRONG_PARAM_COUNT();
2117+
zend_wrong_param_count();
2118+
RETURN_THROWS();
21182119
}
21192120

21202121
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_ASSOC, 0);
@@ -2878,7 +2879,8 @@ PHP_FUNCTION(pg_lo_import)
28782879
CHECK_DEFAULT_LINK(link);
28792880
}
28802881
else {
2881-
ZEND_WRONG_PARAM_COUNT();
2882+
zend_wrong_param_count();
2883+
RETURN_THROWS();
28822884
}
28832885

28842886
if (php_check_open_basedir(ZSTR_VAL(file_in))) {

ext/sockets/sockets.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,8 @@ PHP_FUNCTION(socket_recvfrom)
15801580

15811581
if (arg6 == NULL) {
15821582
zend_string_efree(recv_buf);
1583-
ZEND_WRONG_PARAM_COUNT();
1583+
zend_wrong_param_count();
1584+
RETURN_THROWS();
15841585
}
15851586

15861587
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen);
@@ -1607,7 +1608,8 @@ PHP_FUNCTION(socket_recvfrom)
16071608

16081609
if (arg6 == NULL) {
16091610
zend_string_efree(recv_buf);
1610-
ZEND_WRONG_PARAM_COUNT();
1611+
zend_wrong_param_count();
1612+
RETURN_THROWS();
16111613
}
16121614

16131615
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, (socklen_t *)&slen);

ext/spl/spl_directory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2583,7 +2583,8 @@ PHP_METHOD(SplFileObject, fscanf)
25832583
int result = php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_VAL(format_str), (int)num_varargs, varargs, 0, return_value);
25842584

25852585
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
2586-
ZEND_WRONG_PARAM_COUNT();
2586+
zend_wrong_param_count();
2587+
RETURN_THROWS();
25872588
}
25882589
}
25892590
/* }}} */

ext/standard/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,8 @@ PHP_FUNCTION(fscanf)
961961
efree(buf);
962962

963963
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
964-
ZEND_WRONG_PARAM_COUNT();
964+
zend_wrong_param_count();
965+
RETURN_THROWS();
965966
}
966967
}
967968
/* }}} */

ext/standard/string.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5875,7 +5875,8 @@ PHP_FUNCTION(sscanf)
58755875
result = php_sscanf_internal(str, format, num_args, args, 0, return_value);
58765876

58775877
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
5878-
ZEND_WRONG_PARAM_COUNT();
5878+
zend_wrong_param_count();
5879+
RETURN_THROWS();
58795880
}
58805881
}
58815882
/* }}} */

0 commit comments

Comments
 (0)