summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-06-08 11:10:56 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-06-09 09:46:51 +0200
commit596561009c8d7208db1b6506b68d92eefb11e6a2 (patch)
treec9d718d87865660edc815b77f68ba9baa0ad9e30 /ext
parentcadcefc956fd94a12580f7484caef91116456731 (diff)
downloadphp-git-596561009c8d7208db1b6506b68d92eefb11e6a2.tar.gz
Fix some UNKNOWN default values
In ext/ffi, ext/intl, ext/mysqli, and ext/pcntl
Diffstat (limited to 'ext')
-rw-r--r--ext/ffi/ffi.c7
-rw-r--r--ext/ffi/ffi.stub.php2
-rw-r--r--ext/ffi/ffi_arginfo.h2
-rw-r--r--ext/intl/calendar/calendar_methods.cpp7
-rw-r--r--ext/intl/dateformat/dateformat.stub.php2
-rw-r--r--ext/intl/dateformat/dateformat_arginfo.h2
-rw-r--r--ext/intl/php_intl.stub.php4
-rw-r--r--ext/intl/php_intl_arginfo.h4
-rw-r--r--ext/intl/timezone/timezone.stub.php2
-rw-r--r--ext/intl/timezone/timezone_arginfo.h2
-rw-r--r--ext/intl/timezone/timezone_methods.cpp2
-rw-r--r--ext/mysqli/mysqli.stub.php10
-rw-r--r--ext/mysqli/mysqli_api.c2
-rw-r--r--ext/mysqli/mysqli_arginfo.h6
-rw-r--r--ext/pcntl/pcntl.c26
-rw-r--r--ext/pcntl/pcntl.stub.php6
-rw-r--r--ext/pcntl/pcntl_arginfo.h6
17 files changed, 46 insertions, 46 deletions
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 20e1b67834..59d4738d38 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -4365,18 +4365,19 @@ ZEND_METHOD(FFI, string) /* {{{ */
zend_ffi_cdata *cdata;
zend_ffi_type *type;
void *ptr;
- zend_long size = 0;
+ zend_long size;
+ zend_bool size_is_null = 1;
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_OBJECT_OF_CLASS_EX2(zv, zend_ffi_cdata_ce, 0, 1, 0);
Z_PARAM_OPTIONAL
- Z_PARAM_LONG(size)
+ Z_PARAM_LONG_OR_NULL(size, size_is_null)
ZEND_PARSE_PARAMETERS_END();
cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
type = ZEND_FFI_TYPE(cdata->type);
- if (EX_NUM_ARGS() == 2) {
+ if (!size_is_null) {
if (type->kind == ZEND_FFI_TYPE_POINTER) {
ptr = *(void**)cdata->ptr;
} else {
diff --git a/ext/ffi/ffi.stub.php b/ext/ffi/ffi.stub.php
index 89d1890e61..14b168a6a8 100644
--- a/ext/ffi/ffi.stub.php
+++ b/ext/ffi/ffi.stub.php
@@ -57,7 +57,7 @@ final class FFI
public static function memset(FFI\CData $ptr, int $ch, int $size): void {}
/** @prefer-ref $ptr */
- public static function string(FFI\CData $ptr, int $size = UNKNOWN): ?string {}
+ public static function string(FFI\CData $ptr, ?int $size = null): ?string {}
/** @prefer-ref $ptr */
public static function isNull(FFI\CData $ptr): bool {}
diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h
index 8bd12b0998..10468cb0e7 100644
--- a/ext/ffi/ffi_arginfo.h
+++ b/ext/ffi/ffi_arginfo.h
@@ -71,7 +71,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_string, 0, 1, IS_STRING, 1)
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
- ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, size, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_isNull, 0, 1, _IS_BOOL, 0)
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index cc1f78cba2..45fe97d509 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -389,16 +389,15 @@ U_CFUNC PHP_FUNCTION(intlcal_set)
if (zend_parse_method_parameters(
ZEND_NUM_ARGS(), object, "Oll|llll",
- &object, Calendar_ce_ptr, &args[0], &args[1], &args[2], &args[3], &args[4], &args[5]) == FAILURE
- ) {
+ &object, Calendar_ce_ptr, &args[0], &args[1], &args[2], &args[3], &args[4], &args[5]
+ ) == FAILURE) {
RETURN_THROWS();
}
for (int i = 0; i < arg_num; i++) {
if (args[i] < INT32_MIN || args[i] > INT32_MAX) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "intlcal_set: at least one of the arguments has an absolute "
- "value that is too large", 0);
+ "intlcal_set: at least one of the arguments has an absolute value that is too large", 0);
RETURN_FALSE;
}
}
diff --git a/ext/intl/dateformat/dateformat.stub.php b/ext/intl/dateformat/dateformat.stub.php
index f5ccd271a6..e86c8c93ad 100644
--- a/ext/intl/dateformat/dateformat.stub.php
+++ b/ext/intl/dateformat/dateformat.stub.php
@@ -84,7 +84,7 @@ class IntlDateFormatter
* @return string|false
* @alias datefmt_get_locale
*/
- public function getLocale(int $which = UNKNOWN) {}
+ public function getLocale(int $which = ULOC_ACTUAL_LOCALE) {}
/**
* @return void
diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h
index e6baf4f18a..08bea3335d 100644
--- a/ext/intl/dateformat/dateformat_arginfo.h
+++ b/ext/intl/dateformat/dateformat_arginfo.h
@@ -39,7 +39,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_IntlDateFormatter_getPattern arginfo_class_IntlDateFormatter_getDateType
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getLocale, 0, 0, 0)
- ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, which, IS_LONG, 0, "ULOC_ACTUAL_LOCALE")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setLenient, 0, 0, 1)
diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php
index f1caad8429..337a79c71a 100644
--- a/ext/intl/php_intl.stub.php
+++ b/ext/intl/php_intl.stub.php
@@ -175,7 +175,7 @@ function datefmt_set_pattern(IntlDateFormatter $df, string $pattern): bool {}
function datefmt_get_pattern(IntlDateFormatter $df): string|false {}
-function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN): string|false {}
+function datefmt_get_locale(IntlDateFormatter $df, int $which = ULOC_ACTUAL_LOCALE): string|false {}
function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): void {}
@@ -395,7 +395,7 @@ function intltz_get_unknown(): IntlTimeZone {}
#if U_ICU_VERSION_MAJOR_NUM >= 52
function intltz_get_windows_id(string $timezone): string|false {}
-function intltz_get_id_for_windows_id(string $timezone, string $region = UNKNOWN): string|false {}
+function intltz_get_id_for_windows_id(string $timezone, ?string $region = null): string|false {}
#endif
function intltz_has_same_rules(IntlTimeZone $tz, IntlTimeZone $otherTimeZone): bool {}
diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h
index 5e4731a5fc..9f8b0c12db 100644
--- a/ext/intl/php_intl_arginfo.h
+++ b/ext/intl/php_intl_arginfo.h
@@ -319,7 +319,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
- ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, which, IS_LONG, 0, "ULOC_ACTUAL_LOCALE")
ZEND_END_ARG_INFO()
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()
#if U_ICU_VERSION_MAJOR_NUM >= 52
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intltz_get_id_for_windows_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, region, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#endif
diff --git a/ext/intl/timezone/timezone.stub.php b/ext/intl/timezone/timezone.stub.php
index d34170a281..e470ee8440 100644
--- a/ext/intl/timezone/timezone.stub.php
+++ b/ext/intl/timezone/timezone.stub.php
@@ -132,7 +132,7 @@ class IntlTimeZone
* @return string|false
* @alias intltz_get_id_for_windows_id
*/
- public static function getIDForWindowsID(string $timezone, string $region = UNKNOWN) {}
+ public static function getIDForWindowsID(string $timezone, ?string $region = null) {}
#endif
/**
* @return bool
diff --git a/ext/intl/timezone/timezone_arginfo.h b/ext/intl/timezone/timezone_arginfo.h
index e6fdb2feaa..58dbecf28d 100644
--- a/ext/intl/timezone/timezone_arginfo.h
+++ b/ext/intl/timezone/timezone_arginfo.h
@@ -75,7 +75,7 @@ ZEND_END_ARG_INFO()
#if U_ICU_VERSION_MAJOR_NUM >= 52
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone_getIDForWindowsID, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, region, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#endif
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index d11d8433c6..0414849687 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -648,7 +648,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id)
UnicodeString uWinID, uID;
UErrorCode error;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &winID, &region) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S!", &winID, &region) == FAILURE) {
RETURN_THROWS();
}
diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php
index 786796b892..24224b26e7 100644
--- a/ext/mysqli/mysqli.stub.php
+++ b/ext/mysqli/mysqli.stub.php
@@ -365,7 +365,7 @@ class mysqli_result
* @return object|null
* @alias mysqli_fetch_object
*/
- public function fetch_object(string $class_name = UNKNOWN, array $params = []) {}
+ public function fetch_object(string $class_name = "stdClass", array $params = []) {}
/**
* @return array|null
@@ -579,11 +579,7 @@ function mysqli_fetch_array(mysqli_result $mysql_result, int $fetchtype = MYSQLI
function mysqli_fetch_assoc(mysqli_result $mysql_result): ?array {}
-function mysqli_fetch_object(
- mysqli_result $mysqli_result,
- string $class_name = UNKNOWN,
- array $params = []
-): ?object {}
+function mysqli_fetch_object(mysqli_result $mysqli_result, string $class_name = "stdClass", array $params = []): ?object {}
function mysqli_fetch_row(mysqli_result $mysqli_result): ?array {}
@@ -601,7 +597,7 @@ function mysqli_get_client_stats(): array {}
function mysqli_get_charset(mysqli $mysqli_link): ?object {}
-function mysqli_get_client_info(mysqli $mysqli_link = UNKNOWN): ?string {}
+function mysqli_get_client_info(?mysqli $mysqli_link = null): ?string {}
function mysqli_get_client_version(): int {}
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index b364feec4b..0a360d6a6e 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1370,7 +1370,7 @@ PHP_FUNCTION(mysqli_get_client_info)
} else {
zval *mysql_link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &mysql_link, mysqli_link_class_entry) == FAILURE) {
RETURN_THROWS();
}
}
diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h
index 7145ed5624..b3329c6be6 100644
--- a/ext/mysqli/mysqli_arginfo.h
+++ b/ext/mysqli/mysqli_arginfo.h
@@ -111,7 +111,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_fetch_object, 0, 1, IS_OBJECT, 1)
ZEND_ARG_OBJ_INFO(0, mysqli_result, mysqli_result, 0)
- ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 0, "\"stdClass\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
@@ -148,7 +148,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_get_charset, 0, 1, IS_OBJ
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_get_client_info, 0, 0, IS_STRING, 1)
- ZEND_ARG_OBJ_INFO(0, mysqli_link, mysqli, 0)
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, mysqli_link, mysqli, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_mysqli_get_client_version arginfo_mysqli_connect_errno
@@ -607,7 +607,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_mysqli_result_fetch_assoc arginfo_class_mysqli_character_set_name
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_result_fetch_object, 0, 0, 0)
- ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 0, "\"stdClass\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 6f9fd8a182..6206342168 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -1196,17 +1196,18 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
PHP_FUNCTION(pcntl_getpriority)
{
zend_long who = PRIO_PROCESS;
- zend_long pid = getpid();
+ zend_long pid;
+ zend_bool pid_is_null = 1;
int pri;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &pid, &who) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l", &pid, &who) == FAILURE) {
RETURN_THROWS();
}
/* needs to be cleared, since any returned value is valid */
errno = 0;
- pri = getpriority(who, pid);
+ pri = getpriority(who, pid_is_null ? getpid() : pid);
if (errno) {
PCNTL_G(last_error) = errno;
@@ -1235,14 +1236,15 @@ PHP_FUNCTION(pcntl_getpriority)
PHP_FUNCTION(pcntl_setpriority)
{
zend_long who = PRIO_PROCESS;
- zend_long pid = getpid();
+ zend_long pid;
+ zend_bool pid_is_null = 1;
zend_long pri;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ll", &pri, &pid, &who) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!l", &pri, &pid, &who) == FAILURE) {
RETURN_THROWS();
}
- if (setpriority(who, pid, pri)) {
+ if (setpriority(who, pid_is_null ? getpid() : pid, pri)) {
PCNTL_G(last_error) = errno;
switch (errno) {
case ESRCH:
@@ -1401,14 +1403,16 @@ void pcntl_signal_dispatch()
Enable/disable asynchronous signal handling and return the old setting. */
PHP_FUNCTION(pcntl_async_signals)
{
- zend_bool on;
+ zend_bool on, on_is_null = 1;
- if (ZEND_NUM_ARGS() == 0) {
- RETURN_BOOL(PCNTL_G(async_signals));
- }
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &on) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b!", &on, &on_is_null) == FAILURE) {
RETURN_THROWS();
}
+
+ if (on_is_null) {
+ RETURN_BOOL(PCNTL_G(async_signals));
+ }
+
RETVAL_BOOL(PCNTL_G(async_signals));
PCNTL_G(async_signals) = on;
}
diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php
index 5653244119..8dbc1c48e2 100644
--- a/ext/pcntl/pcntl.stub.php
+++ b/ext/pcntl/pcntl.stub.php
@@ -56,16 +56,16 @@ function pcntl_get_last_error(): int {}
function pcntl_errno(): int {}
#ifdef HAVE_GETPRIORITY
-function pcntl_getpriority(int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): int|false {}
+function pcntl_getpriority(?int $pid = null, int $process_identifier = PRIO_PROCESS): int|false {}
#endif
#ifdef HAVE_SETPRIORITY
-function pcntl_setpriority(int $priority, int $pid = UNKNOWN, int $process_identifier = PRIO_PROCESS): bool{}
+function pcntl_setpriority(int $priority, ?int $pid = null, int $process_identifier = PRIO_PROCESS): bool{}
#endif
function pcntl_strerror(int $errno): string {}
-function pcntl_async_signals(bool $on = UNKNOWN): bool {}
+function pcntl_async_signals(?bool $on = null): bool {}
#ifdef HAVE_UNSHARE
function pcntl_unshare(int $flags): bool {}
diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h
index 3310785cc3..a07033065f 100644
--- a/ext/pcntl/pcntl_arginfo.h
+++ b/ext/pcntl/pcntl_arginfo.h
@@ -91,7 +91,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_GETPRIORITY)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pcntl_getpriority, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
ZEND_END_ARG_INFO()
#endif
@@ -99,7 +99,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_SETPRIORITY)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_setpriority, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, priority, IS_LONG, 0)
- ZEND_ARG_TYPE_INFO(0, pid, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pid, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, process_identifier, IS_LONG, 0, "PRIO_PROCESS")
ZEND_END_ARG_INFO()
#endif
@@ -109,7 +109,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_strerror, 0, 1, IS_STRING,
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_async_signals, 0, 0, _IS_BOOL, 0)
- ZEND_ARG_TYPE_INFO(0, on, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, on, _IS_BOOL, 1, "null")
ZEND_END_ARG_INFO()
#if defined(HAVE_UNSHARE)