]> granicus.if.org Git - php/commitdiff
Fix some UNKNOWN default values
authorMáté Kocsis <kocsismate@woohoolabs.com>
Mon, 8 Jun 2020 09:10:56 +0000 (11:10 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 9 Jun 2020 07:46:51 +0000 (09:46 +0200)
In ext/ffi, ext/intl, ext/mysqli, and ext/pcntl

17 files changed:
ext/ffi/ffi.c
ext/ffi/ffi.stub.php
ext/ffi/ffi_arginfo.h
ext/intl/calendar/calendar_methods.cpp
ext/intl/dateformat/dateformat.stub.php
ext/intl/dateformat/dateformat_arginfo.h
ext/intl/php_intl.stub.php
ext/intl/php_intl_arginfo.h
ext/intl/timezone/timezone.stub.php
ext/intl/timezone/timezone_arginfo.h
ext/intl/timezone/timezone_methods.cpp
ext/mysqli/mysqli.stub.php
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_arginfo.h
ext/pcntl/pcntl.c
ext/pcntl/pcntl.stub.php
ext/pcntl/pcntl_arginfo.h

index 20e1b6783423645eb0bb7100dcd97fdfc01ab2c0..59d4738d38e1fd14023b2183334f942775bc86a5 100644 (file)
@@ -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 {
index 89d1890e61fa9f1c77a07e8ca2dd50bb7aa1a270..14b168a6a80d99ffff1dc5bc85df4c18ed07de5a 100644 (file)
@@ -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 {}
index 8bd12b099865bb09d7dbe1352ff1a296fa9af090..10468cb0e712f7fa4279b8b1a4e9beadf9125b4c 100644 (file)
@@ -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)
index cc1f78cba25438aaf5b591bef1300a0a33fbff60..45fe97d509121876ba2d7ca3cad0cd0ef495b106 100644 (file)
@@ -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;
                }
        }
index f5ccd271a62c79a22bc6170e553a051ce039625f..e86c8c93ada2c6044009f6dc408b560f2c71459f 100644 (file)
@@ -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
index e6baf4f18ac12e527ac954264568182b17f6a966..08bea3335ded23272af0bb7710010ed9c6989c94 100644 (file)
@@ -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)
index f1caad84292445ac14ad11b00cf934fc14ecd22d..337a79c71afef23bfaf1b5d28e4c062325eceda2 100644 (file)
@@ -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 {}
index 5e4731a5fcbf42a0512f3adc2d8f055cf1b26b57..9f8b0c12db525132a53495712849a789337c901b 100644 (file)
@@ -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
 
index d34170a2811592eb4664b5a22b30aeb9adeb0741..e470ee844052d5e8751322d9a09cac8292040772 100644 (file)
@@ -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
index e6fdb2feaa8d429b09cec09f0197e34bd6530010..58dbecf28d9e445fa226530a4453a5a6aa05a7dc 100644 (file)
@@ -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
 
index d11d8433c6eeeaf61b75b5fbe9bd9178457d322a..04148496870a5dc55edb3238d11ab227f465f906 100644 (file)
@@ -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();
        }
 
index 786796b89246b2a311aa884634040fa67e986357..24224b26e7d58ce930a3eb01bd31c782a382621c 100644 (file)
@@ -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 {}
 
index b364feec4b06543358767cd55117b102e16f67bf..0a360d6a6ec4bb66dfdb9e1777257588cbf41b48 100644 (file)
@@ -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();
                }
        }
index 7145ed562444f106696783a9c12895d930c3f90b..b3329c6be64d5191e56880e0f8bf98b149bd73a1 100644 (file)
@@ -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()
 
index 6f9fd8a182081a4463ca1c3f303a580e89c7a2d9..62063421680fc8202f65d56e9a0765b30278a609 100644 (file)
@@ -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;
 }
index 56532441191fafe8064f7f466b066c3f23664711..8dbc1c48e2f3d77476abac2829995124afd0cef2 100644 (file)
@@ -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 {}
index 3310785cc3aa6d4056ff6c37d26cb7ffa3080c52..a07033065f6e9b513ae479cfa1f0196fd140d9fb 100644 (file)
@@ -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)