]> granicus.if.org Git - php/commitdiff
Fix UNKNOWN default values in ext/curl
authorMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 18 Jun 2020 07:26:09 +0000 (09:26 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 18 Jun 2020 11:26:32 +0000 (13:26 +0200)
Closes GH-5734

ext/curl/curl.stub.php
ext/curl/curl_arginfo.h
ext/curl/curl_file.c
ext/curl/curl_file.stub.php
ext/curl/curl_file_arginfo.h
ext/curl/interface.c

index 04edb0f482d8a279dcbfde6005974b24145142f0..c2951b1c6aa316e2725cd0073e6bdeea34a676b4 100644 (file)
@@ -33,11 +33,11 @@ function curl_multi_setopt(CurlMultiHandle $multi_handle, int $option, mixed $va
 
 function curl_exec(CurlHandle $handle): string|bool {}
 
-function curl_file_create(string $filename, string $mimetype = UNKNOWN, string $postname = UNKNOWN): CURLFile {}
+function curl_file_create(string $filename, ?string $mimetype = null, ?string $postname = null): CURLFile {}
 
-function curl_getinfo(CurlHandle $handle, int $option = UNKNOWN): mixed {}
+function curl_getinfo(CurlHandle $handle, ?int $option = null): mixed {}
 
-function curl_init(string $url = UNKNOWN): CurlHandle|false {}
+function curl_init(?string $url = null): CurlHandle|false {}
 
 function curl_multi_add_handle(CurlMultiHandle $multi_handle, CurlHandle $handle): int {}
 
index 77956f1ff98bef2b353fe2e8d990d9bb843116af..d779493aa89ddd9ac318d9e5521a7b4d7981fd06 100644 (file)
@@ -41,17 +41,17 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_curl_file_create, 0, 1, CURLFile, 0)
        ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_getinfo, 0, 1, IS_MIXED, 0)
        ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
-       ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_LONG, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_curl_init, 0, 0, CurlHandle, MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, url, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, url, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_multi_add_handle, 0, 2, IS_LONG, 0)
index bcfc51805172858245838f8d704583800d76dbb0..bb0449c179188919440c4aa4ad298035c054319d 100644 (file)
@@ -35,8 +35,8 @@ static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS)
        ZEND_PARSE_PARAMETERS_START(1,3)
                Z_PARAM_PATH_STR(fname)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STR(mime)
-               Z_PARAM_STR(postname)
+               Z_PARAM_STR_OR_NULL(mime)
+               Z_PARAM_STR_OR_NULL(postname)
        ZEND_PARSE_PARAMETERS_END();
 
        zend_update_property_string(curl_CURLFile_class, cf, "name", sizeof("name")-1, ZSTR_VAL(fname));
index 8b3f46d259fdb196c926348d20e34c98d11f73df..14d775d29377629dccc839753b75eb9bec39dafe 100644 (file)
@@ -4,11 +4,7 @@
 
 class CURLFile
 {
-    public function __construct(
-        string $filename,
-        string $mimetype = UNKNOWN,
-        string $postname = UNKNOWN
-    ) {}
+    public function __construct(string $filename, ?string $mimetype = null, ?string $postname = null) {}
 
     /** @return string */
     public function getFilename() {}
index a3fc79b35ac738e32f64cfe81ab35e685d1ca776..f387589f6a14c767ac9c5542c83512da944761cd 100644 (file)
@@ -2,8 +2,8 @@
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile___construct, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile_getFilename, 0, 0, 0)
index 7e9cbf2fdffc7906dcfe6b93062d48e3c2ded41b..85ac0f0b3078dcd9cc82f933916b5534321d2a8a 100644 (file)
@@ -1861,7 +1861,7 @@ PHP_FUNCTION(curl_init)
 
        ZEND_PARSE_PARAMETERS_START(0,1)
                Z_PARAM_OPTIONAL
-               Z_PARAM_STR(url)
+               Z_PARAM_STR_OR_NULL(url)
        ZEND_PARSE_PARAMETERS_END();
 
        cp = curl_easy_init();
@@ -3008,17 +3008,18 @@ PHP_FUNCTION(curl_getinfo)
 {
        zval            *zid;
        php_curl        *ch;
-       zend_long       option = 0;
+       zend_long       option;
+       zend_bool option_is_null = 1;
 
        ZEND_PARSE_PARAMETERS_START(1, 2)
                Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
                Z_PARAM_OPTIONAL
-               Z_PARAM_LONG(option)
+               Z_PARAM_LONG_OR_NULL(option, option_is_null)
        ZEND_PARSE_PARAMETERS_END();
 
        ch = Z_CURL_P(zid);
 
-       if (ZEND_NUM_ARGS() < 2) {
+       if (option_is_null) {
                char *s_code;
                /* libcurl expects long datatype. So far no cases are known where
                   it would be an issue. Using zend_long would truncate a 64-bit