Skip to content

Commit ed6fbf9

Browse files
committed
Fix UNKNOWN default values in ext/curl
Closes GH-5734
1 parent a43fd3b commit ed6fbf9

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

ext/curl/curl.stub.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ function curl_multi_setopt(CurlMultiHandle $multi_handle, int $option, mixed $va
3333

3434
function curl_exec(CurlHandle $handle): string|bool {}
3535

36-
function curl_file_create(string $filename, string $mimetype = UNKNOWN, string $postname = UNKNOWN): CURLFile {}
36+
function curl_file_create(string $filename, ?string $mimetype = null, ?string $postname = null): CURLFile {}
3737

38-
function curl_getinfo(CurlHandle $handle, int $option = UNKNOWN): mixed {}
38+
function curl_getinfo(CurlHandle $handle, ?int $option = null): mixed {}
3939

40-
function curl_init(string $url = UNKNOWN): CurlHandle|false {}
40+
function curl_init(?string $url = null): CurlHandle|false {}
4141

4242
function curl_multi_add_handle(CurlMultiHandle $multi_handle, CurlHandle $handle): int {}
4343

ext/curl/curl_arginfo.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ ZEND_END_ARG_INFO()
4141

4242
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_curl_file_create, 0, 1, CURLFile, 0)
4343
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
44-
ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
45-
ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
44+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
45+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
4646
ZEND_END_ARG_INFO()
4747

4848
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_getinfo, 0, 1, IS_MIXED, 0)
4949
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
50-
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
50+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_LONG, 1, "null")
5151
ZEND_END_ARG_INFO()
5252

5353
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_curl_init, 0, 0, CurlHandle, MAY_BE_FALSE)
54-
ZEND_ARG_TYPE_INFO(0, url, IS_STRING, 0)
54+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, url, IS_STRING, 1, "null")
5555
ZEND_END_ARG_INFO()
5656

5757
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_multi_add_handle, 0, 2, IS_LONG, 0)

ext/curl/curl_file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS)
3535
ZEND_PARSE_PARAMETERS_START(1,3)
3636
Z_PARAM_PATH_STR(fname)
3737
Z_PARAM_OPTIONAL
38-
Z_PARAM_STR(mime)
39-
Z_PARAM_STR(postname)
38+
Z_PARAM_STR_OR_NULL(mime)
39+
Z_PARAM_STR_OR_NULL(postname)
4040
ZEND_PARSE_PARAMETERS_END();
4141

4242
zend_update_property_string(curl_CURLFile_class, cf, "name", sizeof("name")-1, ZSTR_VAL(fname));

ext/curl/curl_file.stub.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
class CURLFile
66
{
7-
public function __construct(
8-
string $filename,
9-
string $mimetype = UNKNOWN,
10-
string $postname = UNKNOWN
11-
) {}
7+
public function __construct(string $filename, ?string $mimetype = null, ?string $postname = null) {}
128

139
/** @return string */
1410
public function getFilename() {}

ext/curl/curl_file_arginfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile___construct, 0, 0, 1)
44
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
5-
ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
6-
ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
5+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
6+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
77
ZEND_END_ARG_INFO()
88

99
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile_getFilename, 0, 0, 0)

ext/curl/interface.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ PHP_FUNCTION(curl_init)
18611861

18621862
ZEND_PARSE_PARAMETERS_START(0,1)
18631863
Z_PARAM_OPTIONAL
1864-
Z_PARAM_STR(url)
1864+
Z_PARAM_STR_OR_NULL(url)
18651865
ZEND_PARSE_PARAMETERS_END();
18661866

18671867
cp = curl_easy_init();
@@ -3008,17 +3008,18 @@ PHP_FUNCTION(curl_getinfo)
30083008
{
30093009
zval *zid;
30103010
php_curl *ch;
3011-
zend_long option = 0;
3011+
zend_long option;
3012+
zend_bool option_is_null = 1;
30123013

30133014
ZEND_PARSE_PARAMETERS_START(1, 2)
30143015
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
30153016
Z_PARAM_OPTIONAL
3016-
Z_PARAM_LONG(option)
3017+
Z_PARAM_LONG_OR_NULL(option, option_is_null)
30173018
ZEND_PARSE_PARAMETERS_END();
30183019

30193020
ch = Z_CURL_P(zid);
30203021

3021-
if (ZEND_NUM_ARGS() < 2) {
3022+
if (option_is_null) {
30223023
char *s_code;
30233024
/* libcurl expects long datatype. So far no cases are known where
30243025
it would be an issue. Using zend_long would truncate a 64-bit

0 commit comments

Comments
 (0)