]> granicus.if.org Git - php/commitdiff
Switch few functions useful in Symphony apps to new ZPP API.
authorDmitry Stogov <dmitry@zend.com>
Wed, 24 Feb 2021 16:13:11 +0000 (19:13 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 24 Feb 2021 16:13:11 +0000 (19:13 +0300)
Zend/zend_builtin_functions.c
Zend/zend_closures.c
ext/spl/php_spl.c

index 94a9502bc968cb8ea94548ab25b3d59b98e34b45..519bf02d88ec4a9b0122ace81980fd58b39f101a 100644 (file)
@@ -1069,23 +1069,25 @@ ZEND_FUNCTION(function_exists)
 ZEND_FUNCTION(class_alias)
 {
        zend_string *class_name;
-       char *alias_name;
+       zend_string *alias_name;
        zend_class_entry *ce;
-       size_t alias_name_len;
        bool autoload = 1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ss|b", &class_name, &alias_name, &alias_name_len, &autoload) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STR(class_name)
+               Z_PARAM_STR(alias_name)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_BOOL(autoload)
+       ZEND_PARSE_PARAMETERS_END();
 
        ce = zend_lookup_class_ex(class_name, NULL, !autoload ? ZEND_FETCH_CLASS_NO_AUTOLOAD : 0);
 
        if (ce) {
                if (ce->type == ZEND_USER_CLASS) {
-                       if (zend_register_class_alias_ex(alias_name, alias_name_len, ce, 0) == SUCCESS) {
+                       if (zend_register_class_alias_ex(ZSTR_VAL(alias_name), ZSTR_LEN(alias_name), ce, 0) == SUCCESS) {
                                RETURN_TRUE;
                        } else {
-                               zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), alias_name);
+                               zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(alias_name));
                                RETURN_FALSE;
                        }
                } else {
@@ -1152,10 +1154,11 @@ ZEND_FUNCTION(set_error_handler)
        zend_fcall_info_cache fcc;
        zend_long error_type = E_ALL;
 
-       /* callable argument corresponds to the error handler */
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|l", &fci, &fcc, &error_type) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_FUNC_OR_NULL(fci, fcc)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(error_type)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) {
                ZVAL_COPY(return_value, &EG(user_error_handler));
@@ -1209,10 +1212,9 @@ ZEND_FUNCTION(set_exception_handler)
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;
 
-       /* callable argument corresponds to the exception handler */
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!", &fci, &fcc) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_FUNC_OR_NULL(fci, fcc)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
                ZVAL_COPY(return_value, &EG(user_exception_handler));
index 8e5b599e39a74a4d91b48f6030cb0ee0cea7e7cc..452f99e6fb3c134bb7a98c2e8fe6f4faefc95db9 100644 (file)
@@ -356,9 +356,9 @@ ZEND_METHOD(Closure, fromCallable)
        zval *callable;
        char *error = NULL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callable) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ZVAL(callable)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (Z_TYPE_P(callable) == IS_OBJECT && instanceof_function(Z_OBJCE_P(callable), zend_ce_closure)) {
                /* It's already a closure */
index 67f87774a0b60a389715732482f82d2bfc3bd69a..5981d2385f0c79ed22067f3fd2a6f013a8708c15 100644 (file)
@@ -569,9 +569,9 @@ PHP_FUNCTION(spl_autoload_unregister)
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) {
-               RETURN_THROWS();
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_FUNC(fci, fcc)
+       ZEND_PARSE_PARAMETERS_END();
 
        if (fcc.function_handler && zend_string_equals_literal(
                        fcc.function_handler->common.function_name, "spl_autoload_call")) {