Skip to content

Commit 5caf29a

Browse files
committed
Switch few functions useful in Symphony apps to new ZPP API.
1 parent 99d0f50 commit 5caf29a

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

Zend/zend_builtin_functions.c

+17-15
Original file line numberDiff line numberDiff line change
@@ -1069,23 +1069,25 @@ ZEND_FUNCTION(function_exists)
10691069
ZEND_FUNCTION(class_alias)
10701070
{
10711071
zend_string *class_name;
1072-
char *alias_name;
1072+
zend_string *alias_name;
10731073
zend_class_entry *ce;
1074-
size_t alias_name_len;
10751074
bool autoload = 1;
10761075

1077-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ss|b", &class_name, &alias_name, &alias_name_len, &autoload) == FAILURE) {
1078-
RETURN_THROWS();
1079-
}
1076+
ZEND_PARSE_PARAMETERS_START(2, 3)
1077+
Z_PARAM_STR(class_name)
1078+
Z_PARAM_STR(alias_name)
1079+
Z_PARAM_OPTIONAL
1080+
Z_PARAM_BOOL(autoload)
1081+
ZEND_PARSE_PARAMETERS_END();
10801082

10811083
ce = zend_lookup_class_ex(class_name, NULL, !autoload ? ZEND_FETCH_CLASS_NO_AUTOLOAD : 0);
10821084

10831085
if (ce) {
10841086
if (ce->type == ZEND_USER_CLASS) {
1085-
if (zend_register_class_alias_ex(alias_name, alias_name_len, ce, 0) == SUCCESS) {
1087+
if (zend_register_class_alias_ex(ZSTR_VAL(alias_name), ZSTR_LEN(alias_name), ce, 0) == SUCCESS) {
10861088
RETURN_TRUE;
10871089
} else {
1088-
zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), alias_name);
1090+
zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(alias_name));
10891091
RETURN_FALSE;
10901092
}
10911093
} else {
@@ -1152,10 +1154,11 @@ ZEND_FUNCTION(set_error_handler)
11521154
zend_fcall_info_cache fcc;
11531155
zend_long error_type = E_ALL;
11541156

1155-
/* callable argument corresponds to the error handler */
1156-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|l", &fci, &fcc, &error_type) == FAILURE) {
1157-
RETURN_THROWS();
1158-
}
1157+
ZEND_PARSE_PARAMETERS_START(1, 2)
1158+
Z_PARAM_FUNC_OR_NULL(fci, fcc)
1159+
Z_PARAM_OPTIONAL
1160+
Z_PARAM_LONG(error_type)
1161+
ZEND_PARSE_PARAMETERS_END();
11591162

11601163
if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
11611164
ZVAL_COPY(return_value, &EG(user_error_handler));
@@ -1209,10 +1212,9 @@ ZEND_FUNCTION(set_exception_handler)
12091212
zend_fcall_info fci;
12101213
zend_fcall_info_cache fcc;
12111214

1212-
/* callable argument corresponds to the exception handler */
1213-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!", &fci, &fcc) == FAILURE) {
1214-
RETURN_THROWS();
1215-
}
1215+
ZEND_PARSE_PARAMETERS_START(1, 1)
1216+
Z_PARAM_FUNC_OR_NULL(fci, fcc)
1217+
ZEND_PARSE_PARAMETERS_END();
12161218

12171219
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
12181220
ZVAL_COPY(return_value, &EG(user_exception_handler));

Zend/zend_closures.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ ZEND_METHOD(Closure, fromCallable)
356356
zval *callable;
357357
char *error = NULL;
358358

359-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callable) == FAILURE) {
360-
RETURN_THROWS();
361-
}
359+
ZEND_PARSE_PARAMETERS_START(1, 1)
360+
Z_PARAM_ZVAL(callable)
361+
ZEND_PARSE_PARAMETERS_END();
362362

363363
if (Z_TYPE_P(callable) == IS_OBJECT && instanceof_function(Z_OBJCE_P(callable), zend_ce_closure)) {
364364
/* It's already a closure */

ext/spl/php_spl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,9 @@ PHP_FUNCTION(spl_autoload_unregister)
569569
zend_fcall_info fci;
570570
zend_fcall_info_cache fcc;
571571

572-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) {
573-
RETURN_THROWS();
574-
}
572+
ZEND_PARSE_PARAMETERS_START(1, 1)
573+
Z_PARAM_FUNC(fci, fcc)
574+
ZEND_PARSE_PARAMETERS_END();
575575

576576
if (fcc.function_handler && zend_string_equals_literal(
577577
fcc.function_handler->common.function_name, "spl_autoload_call")) {

0 commit comments

Comments
 (0)