Skip to content

Commit 553dbf5

Browse files
committed
Fix UNKNOWN default values in ext/curl
1 parent 4050db6 commit 553dbf5

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

ext/curl/curl.stub.php

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ PHP_FUNCTION(curl_init)
18711871

18721872
ZEND_PARSE_PARAMETERS_START(0,1)
18731873
Z_PARAM_OPTIONAL
1874-
Z_PARAM_STR(url)
1874+
Z_PARAM_STR_OR_NULL(url)
18751875
ZEND_PARSE_PARAMETERS_END();
18761876

18771877
cp = curl_easy_init();
@@ -3018,17 +3018,18 @@ PHP_FUNCTION(curl_getinfo)
30183018
{
30193019
zval *zid;
30203020
php_curl *ch;
3021-
zend_long option = 0;
3021+
zend_long option;
3022+
zend_bool option_is_null = 1;
30223023

30233024
ZEND_PARSE_PARAMETERS_START(1, 2)
30243025
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
30253026
Z_PARAM_OPTIONAL
3026-
Z_PARAM_LONG(option)
3027+
Z_PARAM_LONG_OR_NULL(option, option_is_null)
30273028
ZEND_PARSE_PARAMETERS_END();
30283029

30293030
ch = Z_CURL_P(zid);
30303031

3031-
if (ZEND_NUM_ARGS() < 2) {
3032+
if (option_is_null) {
30323033
char *s_code;
30333034
/* libcurl expects long datatype. So far no cases are known where
30343035
it would be an issue. Using zend_long would truncate a 64-bit

0 commit comments

Comments
 (0)