Skip to content

Commit 5965610

Browse files
committed
Fix some UNKNOWN default values
In ext/ffi, ext/intl, ext/mysqli, and ext/pcntl
1 parent cadcefc commit 5965610

17 files changed

+46
-46
lines changed

ext/ffi/ffi.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -4365,18 +4365,19 @@ ZEND_METHOD(FFI, string) /* {{{ */
43654365
zend_ffi_cdata *cdata;
43664366
zend_ffi_type *type;
43674367
void *ptr;
4368-
zend_long size = 0;
4368+
zend_long size;
4369+
zend_bool size_is_null = 1;
43694370

43704371
ZEND_FFI_VALIDATE_API_RESTRICTION();
43714372
ZEND_PARSE_PARAMETERS_START(1, 2)
43724373
Z_PARAM_OBJECT_OF_CLASS_EX2(zv, zend_ffi_cdata_ce, 0, 1, 0);
43734374
Z_PARAM_OPTIONAL
4374-
Z_PARAM_LONG(size)
4375+
Z_PARAM_LONG_OR_NULL(size, size_is_null)
43754376
ZEND_PARSE_PARAMETERS_END();
43764377

43774378
cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
43784379
type = ZEND_FFI_TYPE(cdata->type);
4379-
if (EX_NUM_ARGS() == 2) {
4380+
if (!size_is_null) {
43804381
if (type->kind == ZEND_FFI_TYPE_POINTER) {
43814382
ptr = *(void**)cdata->ptr;
43824383
} else {

ext/ffi/ffi.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function memcmp($ptr1, $ptr2, int $size): ?int {}
5757
public static function memset(FFI\CData $ptr, int $ch, int $size): void {}
5858

5959
/** @prefer-ref $ptr */
60-
public static function string(FFI\CData $ptr, int $size = UNKNOWN): ?string {}
60+
public static function string(FFI\CData $ptr, ?int $size = null): ?string {}
6161

6262
/** @prefer-ref $ptr */
6363
public static function isNull(FFI\CData $ptr): bool {}

ext/ffi/ffi_arginfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ZEND_END_ARG_INFO()
7171

7272
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_string, 0, 1, IS_STRING, 1)
7373
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
74-
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
74+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, size, IS_LONG, 1, "null")
7575
ZEND_END_ARG_INFO()
7676

7777
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_isNull, 0, 1, _IS_BOOL, 0)

ext/intl/calendar/calendar_methods.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,15 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
389389

390390
if (zend_parse_method_parameters(
391391
ZEND_NUM_ARGS(), object, "Oll|llll",
392-
&object, Calendar_ce_ptr, &args[0], &args[1], &args[2], &args[3], &args[4], &args[5]) == FAILURE
393-
) {
392+
&object, Calendar_ce_ptr, &args[0], &args[1], &args[2], &args[3], &args[4], &args[5]
393+
) == FAILURE) {
394394
RETURN_THROWS();
395395
}
396396

397397
for (int i = 0; i < arg_num; i++) {
398398
if (args[i] < INT32_MIN || args[i] > INT32_MAX) {
399399
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
400-
"intlcal_set: at least one of the arguments has an absolute "
401-
"value that is too large", 0);
400+
"intlcal_set: at least one of the arguments has an absolute value that is too large", 0);
402401
RETURN_FALSE;
403402
}
404403
}

ext/intl/dateformat/dateformat.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getPattern() {}
8484
* @return string|false
8585
* @alias datefmt_get_locale
8686
*/
87-
public function getLocale(int $which = UNKNOWN) {}
87+
public function getLocale(int $which = ULOC_ACTUAL_LOCALE) {}
8888

8989
/**
9090
* @return void

ext/intl/dateformat/dateformat_arginfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ZEND_END_ARG_INFO()
3939
#define arginfo_class_IntlDateFormatter_getPattern arginfo_class_IntlDateFormatter_getDateType
4040

4141
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getLocale, 0, 0, 0)
42-
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
42+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, which, IS_LONG, 0, "ULOC_ACTUAL_LOCALE")
4343
ZEND_END_ARG_INFO()
4444

4545
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setLenient, 0, 0, 1)

ext/intl/php_intl.stub.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function datefmt_set_pattern(IntlDateFormatter $df, string $pattern): bool {}
175175

176176
function datefmt_get_pattern(IntlDateFormatter $df): string|false {}
177177

178-
function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN): string|false {}
178+
function datefmt_get_locale(IntlDateFormatter $df, int $which = ULOC_ACTUAL_LOCALE): string|false {}
179179

180180
function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): void {}
181181

@@ -395,7 +395,7 @@ function intltz_get_unknown(): IntlTimeZone {}
395395
#if U_ICU_VERSION_MAJOR_NUM >= 52
396396
function intltz_get_windows_id(string $timezone): string|false {}
397397

398-
function intltz_get_id_for_windows_id(string $timezone, string $region = UNKNOWN): string|false {}
398+
function intltz_get_id_for_windows_id(string $timezone, ?string $region = null): string|false {}
399399
#endif
400400

401401
function intltz_has_same_rules(IntlTimeZone $tz, IntlTimeZone $otherTimeZone): bool {}

ext/intl/php_intl_arginfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ ZEND_END_ARG_INFO()
319319

320320
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
321321
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
322-
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
322+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, which, IS_LONG, 0, "ULOC_ACTUAL_LOCALE")
323323
ZEND_END_ARG_INFO()
324324

325325
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_lenient, 0, 2, IS_VOID, 0)
@@ -723,7 +723,7 @@ ZEND_END_ARG_INFO()
723723
#if U_ICU_VERSION_MAJOR_NUM >= 52
724724
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intltz_get_id_for_windows_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
725725
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
726-
ZEND_ARG_TYPE_INFO(0, region, IS_STRING, 0)
726+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null")
727727
ZEND_END_ARG_INFO()
728728
#endif
729729

ext/intl/timezone/timezone.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function getWindowsID(string $timezone) {}
132132
* @return string|false
133133
* @alias intltz_get_id_for_windows_id
134134
*/
135-
public static function getIDForWindowsID(string $timezone, string $region = UNKNOWN) {}
135+
public static function getIDForWindowsID(string $timezone, ?string $region = null) {}
136136
#endif
137137
/**
138138
* @return bool

ext/intl/timezone/timezone_arginfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ZEND_END_ARG_INFO()
7575
#if U_ICU_VERSION_MAJOR_NUM >= 52
7676
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone_getIDForWindowsID, 0, 0, 1)
7777
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
78-
ZEND_ARG_TYPE_INFO(0, region, IS_STRING, 0)
78+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null")
7979
ZEND_END_ARG_INFO()
8080
#endif
8181

ext/intl/timezone/timezone_methods.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id)
648648
UnicodeString uWinID, uID;
649649
UErrorCode error;
650650

651-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &winID, &region) == FAILURE) {
651+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S!", &winID, &region) == FAILURE) {
652652
RETURN_THROWS();
653653
}
654654

ext/mysqli/mysqli.stub.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public function fetch_assoc() {}
365365
* @return object|null
366366
* @alias mysqli_fetch_object
367367
*/
368-
public function fetch_object(string $class_name = UNKNOWN, array $params = []) {}
368+
public function fetch_object(string $class_name = "stdClass", array $params = []) {}
369369

370370
/**
371371
* @return array|null
@@ -579,11 +579,7 @@ function mysqli_fetch_array(mysqli_result $mysql_result, int $fetchtype = MYSQLI
579579

580580
function mysqli_fetch_assoc(mysqli_result $mysql_result): ?array {}
581581

582-
function mysqli_fetch_object(
583-
mysqli_result $mysqli_result,
584-
string $class_name = UNKNOWN,
585-
array $params = []
586-
): ?object {}
582+
function mysqli_fetch_object(mysqli_result $mysqli_result, string $class_name = "stdClass", array $params = []): ?object {}
587583

588584
function mysqli_fetch_row(mysqli_result $mysqli_result): ?array {}
589585

@@ -601,7 +597,7 @@ function mysqli_get_client_stats(): array {}
601597

602598
function mysqli_get_charset(mysqli $mysqli_link): ?object {}
603599

604-
function mysqli_get_client_info(mysqli $mysqli_link = UNKNOWN): ?string {}
600+
function mysqli_get_client_info(?mysqli $mysqli_link = null): ?string {}
605601

606602
function mysqli_get_client_version(): int {}
607603

ext/mysqli/mysqli_api.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ PHP_FUNCTION(mysqli_get_client_info)
13701370
} else {
13711371
zval *mysql_link;
13721372

1373-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
1373+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &mysql_link, mysqli_link_class_entry) == FAILURE) {
13741374
RETURN_THROWS();
13751375
}
13761376
}

ext/mysqli/mysqli_arginfo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ ZEND_END_ARG_INFO()
111111

112112
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_fetch_object, 0, 1, IS_OBJECT, 1)
113113
ZEND_ARG_OBJ_INFO(0, mysqli_result, mysqli_result, 0)
114-
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
114+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 0, "\"stdClass\"")
115115
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 0, "[]")
116116
ZEND_END_ARG_INFO()
117117

@@ -148,7 +148,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_get_charset, 0, 1, IS_OBJ
148148
ZEND_END_ARG_INFO()
149149

150150
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_get_client_info, 0, 0, IS_STRING, 1)
151-
ZEND_ARG_OBJ_INFO(0, mysqli_link, mysqli, 0)
151+
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, mysqli_link, mysqli, 1, "null")
152152
ZEND_END_ARG_INFO()
153153

154154
#define arginfo_mysqli_get_client_version arginfo_mysqli_connect_errno
@@ -607,7 +607,7 @@ ZEND_END_ARG_INFO()
607607
#define arginfo_class_mysqli_result_fetch_assoc arginfo_class_mysqli_character_set_name
608608

609609
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_result_fetch_object, 0, 0, 0)
610-
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
610+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 0, "\"stdClass\"")
611611
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 0, "[]")
612612
ZEND_END_ARG_INFO()
613613

ext/pcntl/pcntl.c

+15-11
Original file line numberDiff line numberDiff line change
@@ -1196,17 +1196,18 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
11961196
PHP_FUNCTION(pcntl_getpriority)
11971197
{
11981198
zend_long who = PRIO_PROCESS;
1199-
zend_long pid = getpid();
1199+
zend_long pid;
1200+
zend_bool pid_is_null = 1;
12001201
int pri;
12011202

1202-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &pid, &who) == FAILURE) {
1203+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l", &pid, &who) == FAILURE) {
12031204
RETURN_THROWS();
12041205
}
12051206

12061207
/* needs to be cleared, since any returned value is valid */
12071208
errno = 0;
12081209

1209-
pri = getpriority(who, pid);
1210+
pri = getpriority(who, pid_is_null ? getpid() : pid);
12101211

12111212
if (errno) {
12121213
PCNTL_G(last_error) = errno;
@@ -1235,14 +1236,15 @@ PHP_FUNCTION(pcntl_getpriority)
12351236
PHP_FUNCTION(pcntl_setpriority)
12361237
{
12371238
zend_long who = PRIO_PROCESS;
1238-
zend_long pid = getpid();
1239+
zend_long pid;
1240+
zend_bool pid_is_null = 1;
12391241
zend_long pri;
12401242

1241-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ll", &pri, &pid, &who) == FAILURE) {
1243+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!l", &pri, &pid, &who) == FAILURE) {
12421244
RETURN_THROWS();
12431245
}
12441246

1245-
if (setpriority(who, pid, pri)) {
1247+
if (setpriority(who, pid_is_null ? getpid() : pid, pri)) {
12461248
PCNTL_G(last_error) = errno;
12471249
switch (errno) {
12481250
case ESRCH:
@@ -1401,14 +1403,16 @@ void pcntl_signal_dispatch()
14011403
Enable/disable asynchronous signal handling and return the old setting. */
14021404
PHP_FUNCTION(pcntl_async_signals)
14031405
{
1404-
zend_bool on;
1406+
zend_bool on, on_is_null = 1;
14051407

1406-
if (ZEND_NUM_ARGS() == 0) {
1407-
RETURN_BOOL(PCNTL_G(async_signals));
1408-
}
1409-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &on) == FAILURE) {
1408+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b!", &on, &on_is_null) == FAILURE) {
14101409
RETURN_THROWS();
14111410
}
1411+
1412+
if (on_is_null) {
1413+
RETURN_BOOL(PCNTL_G(async_signals));
1414+
}
1415+
14121416
RETVAL_BOOL(PCNTL_G(async_signals));
14131417
PCNTL_G(async_signals) = on;
14141418
}

ext/pcntl/pcntl.stub.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ function pcntl_get_last_error(): int {}
5656
function pcntl_errno(): int {}
5757

5858
#ifdef HAVE_GETPRIORITY
59-
function pcntl_getpriority(int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): int|false {}
59+
function pcntl_getpriority(?int $pid = null, int $process_identifier = PRIO_PROCESS): int|false {}
6060
#endif
6161

6262
#ifdef HAVE_SETPRIORITY
63-
function pcntl_setpriority(int $priority, int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): bool{}
63+
function pcntl_setpriority(int $priority, ?int $pid = null, int $process_identifier = PRIO_PROCESS): bool{}
6464
#endif
6565

6666
function pcntl_strerror(int $errno): string {}
6767

68-
function pcntl_async_signals(bool $on = UNKNOWN): bool {}
68+
function pcntl_async_signals(?bool $on = null): bool {}
6969

7070
#ifdef HAVE_UNSHARE
7171
function pcntl_unshare(int $flags): bool {}

ext/pcntl/pcntl_arginfo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ ZEND_END_ARG_INFO()
9191

9292
#if defined(HAVE_GETPRIORITY)
9393
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_getpriority, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
94-
ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
94+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
9595
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
9696
ZEND_END_ARG_INFO()
9797
#endif
9898

9999
#if defined(HAVE_SETPRIORITY)
100100
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_setpriority, 0, 1, _IS_BOOL, 0)
101101
ZEND_ARG_TYPE_INFO(0, priority, IS_LONG, 0)
102-
ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
102+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
103103
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
104104
ZEND_END_ARG_INFO()
105105
#endif
@@ -109,7 +109,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_strerror, 0, 1, IS_STRING,
109109
ZEND_END_ARG_INFO()
110110

111111
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_async_signals, 0, 0, _IS_BOOL, 0)
112-
ZEND_ARG_TYPE_INFO(0, on, _IS_BOOL, 0)
112+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, on, _IS_BOOL, 1, "null")
113113
ZEND_END_ARG_INFO()
114114

115115
#if defined(HAVE_UNSHARE)

0 commit comments

Comments
 (0)