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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)