]> granicus.if.org Git - php/commitdiff
Fix UNKNOWN default values in various extensions
authorMáté Kocsis <kocsismate@woohoolabs.com>
Sat, 2 May 2020 13:25:25 +0000 (15:25 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 5 May 2020 17:08:20 +0000 (19:08 +0200)
Closes GH-5514

25 files changed:
Zend/zend_API.h
ext/dom/php_dom.stub.php
ext/dom/php_dom_arginfo.h
ext/enchant/enchant.c
ext/enchant/enchant.stub.php
ext/enchant/enchant_arginfo.h
ext/ffi/ffi.c
ext/ffi/ffi.stub.php
ext/ffi/ffi_arginfo.h
ext/ftp/ftp.stub.php
ext/ftp/ftp_arginfo.h
ext/hash/hash.c
ext/hash/hash.stub.php
ext/hash/hash_arginfo.h
ext/iconv/iconv.c
ext/iconv/iconv.stub.php
ext/iconv/iconv_arginfo.h
ext/libxml/libxml.c
ext/libxml/libxml.stub.php
ext/libxml/libxml_arginfo.h
ext/mysqli/mysqli.c
ext/mysqli/mysqli.stub.php
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_arginfo.h
ext/mysqli/mysqli_nonapi.c

index 0e361ad7c5902a3e3489271500c21b7de038421f..f97f54af44a409aabf09e76b5e8ac919b6615127 100644 (file)
@@ -1327,6 +1327,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
 #define Z_PARAM_BOOL(dest) \
        Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
 
+#define Z_PARAM_BOOL_OR_NULL(dest, is_null) \
+       Z_PARAM_BOOL_EX(dest, is_null, 1, 0)
+
 /* old "C" */
 #define Z_PARAM_CLASS_EX2(dest, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
@@ -1558,6 +1561,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
 #define Z_PARAM_STR(dest) \
        Z_PARAM_STR_EX(dest, 0, 0)
 
+#define Z_PARAM_STR_OR_NULL(dest) \
+       Z_PARAM_STR_EX(dest, 1, 0)
+
 /* old "z" */
 #define Z_PARAM_ZVAL_EX2(dest, check_null, deref, separate) \
                Z_PARAM_PROLOGUE(deref, separate); \
index 8f1b3754714db9e5b16e7923b12e4afb0c3a8019..3d77b136c79f0ec35c6a6383b72af37e180bb962 100644 (file)
@@ -103,11 +103,10 @@ class DOMImplementation
     public function hasFeature(string $feature, string $version) {}
 
     /** @return DOMDocumentType|false */
-    public function createDocumentType(
-        string $qualifiedName, string $publicId = "", string $systemId = "") {}
+    public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
 
     /** @return DOMDocument|false */
-    public function createDocument(string $namespaceURI = "", string $qualifiedName = "", DOMDocumentType $doctype = UNKNOWN) {}
+    public function createDocument(string $namespaceURI = "", string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
 }
 
 class DOMDocumentFragment implements DOMParentNode
@@ -248,7 +247,7 @@ class DOMElement implements DOMParentNode, DOMChildNode
 
 class DOMDocument implements DOMParentNode
 {
-    public function __construct(string $version = "1.0", string $encoding = UNKNOWN) {}
+    public function __construct(string $version = "1.0", string $encoding = "") {}
 
     /** @return DOMAttr|false */
     public function createAttribute(string $name) {}
index e9893013115314fa1c956087d0c289e4f410782f..c7fd0c81df44fae321f3f67549424b15b58c95fe 100644 (file)
@@ -107,7 +107,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMImplementation_createDocument, 0, 0, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, namespaceURI, IS_STRING, 0, "\"\"")
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, qualifiedName, IS_STRING, 0, "\"\"")
-       ZEND_ARG_OBJ_INFO(0, doctype, DOMDocumentType, 0)
+       ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, doctype, DOMDocumentType, 1, "null")
 ZEND_END_ARG_INFO()
 
 #define arginfo_class_DOMDocumentFragment___construct arginfo_class_DOMNode_getLineNo
@@ -244,7 +244,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMDocument___construct, 0, 0, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, version, IS_STRING, 0, "\"1.0\"")
-       ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"")
 ZEND_END_ARG_INFO()
 
 #define arginfo_class_DOMDocument_createAttribute arginfo_class_DOMElement_getAttribute
index 01955553797d25118425a7407ff3b6b13f871996..1c43323f95e7e4b05903d656f35ad4dcb70b3785 100644 (file)
@@ -656,9 +656,9 @@ PHP_FUNCTION(enchant_dict_quick_check)
                        enchant_dict_free_string_list(pdict->pdict, suggs);
                }
 
-
                RETURN_FALSE;
        }
+
        RETURN_TRUE;
 }
 /* }}} */
index cad28b91038606e807aaa049dac023fa542d1240..f235ff59ba9f4fa13ad43e68784103954d87c70f 100644 (file)
@@ -54,7 +54,7 @@ function enchant_broker_set_ordering($broker, string $tag, string $ordering): bo
 function enchant_broker_describe($broker): array {}
 
 /** @param resource $dict */
-function enchant_dict_quick_check($dict, string $word, &$suggestions = UNKNOWN): bool {}
+function enchant_dict_quick_check($dict, string $word, &$suggestions = null): bool {}
 
 /** @param resource $dict */
 function enchant_dict_check($dict, string $word): bool {}
index 967bdfcf72915b333abd82628063a2ba695be08c..b0906d9a3dfdc771799762b453f45adab271e575 100644 (file)
@@ -56,7 +56,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_quick_check, 0, 2, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, dict)
        ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0)
-       ZEND_ARG_INFO(1, suggestions)
+       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, suggestions, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_check, 0, 2, _IS_BOOL, 0)
index 1ca8a9be7568d1172a914910c722e392795e46de..7784c7b3894bcda185f3b934cf80dcd8c08675ba 100644 (file)
@@ -2835,7 +2835,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
        ZEND_PARSE_PARAMETERS_START(0, 2)
                Z_PARAM_OPTIONAL
                Z_PARAM_STR(code)
-               Z_PARAM_STR(lib)
+               Z_PARAM_STR_OR_NULL(lib)
        ZEND_PARSE_PARAMETERS_END();
 
        if (lib) {
@@ -2854,7 +2854,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
        FFI_G(symbols) = NULL;
        FFI_G(tags) = NULL;
 
-       if (code) {
+       if (code && ZSTR_LEN(code)) {
                /* Parse C definitions */
                FFI_G(default_type_attr) = ZEND_FFI_ATTR_STORED;
 
index a45235469e7a6d4838a010136edce61f36c80ba7..89d1890e61fa9f1c77a07e8ca2dd50bb7aa1a270 100644 (file)
@@ -4,7 +4,7 @@
 
 final class FFI
 {
-    public static function cdef(string $code = UNKNOWN, string $lib = UNKNOWN): FFI {}
+    public static function cdef(string $code = "", ?string $lib = null): FFI {}
 
     public static function load(string $filename): ?FFI {}
 
index 009512fe827dab00819e40bbb4896ce12cfb6d9a..8bd12b099865bb09d7dbe1352ff1a296fa9af090 100644 (file)
@@ -1,8 +1,8 @@
 /* This is a generated file, edit the .stub.php file instead. */
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
-       ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, lib, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, lib, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_load, 0, 1, FFI, 1)
index 72b712684390d5769afb61a441ee34ad215cc588..b293c453fadc5c9d3dcf5a4e8cb5f8703e5141b4 100644 (file)
@@ -38,7 +38,7 @@ function ftp_rmdir($ftp, string $directory): bool {}
 function ftp_chmod($ftp, int $mode, string $filename): int|false {}
 
 /** @param resource $ftp */
-function ftp_alloc($ftp, int $size, &$response = UNKNOWN): bool {}
+function ftp_alloc($ftp, int $size, &$response = null): bool {}
 
 /** @param resource $ftp */
 function ftp_nlist($ftp, string $directory): array|false {}
index 83e7b672f426855f2915fa2bc21c90c13172a274..738f8e9284d3b3ede18c23c75e0fcbcd8a0c7865 100644 (file)
@@ -59,7 +59,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ftp_alloc, 0, 2, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, ftp)
        ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
-       ZEND_ARG_INFO(1, response)
+       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ftp_nlist, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
index 25c816d47a2c63756c06ed863f27a080d996085d..31ead3716379582e44a015bf9eb9df5f9a7aa0fd 100644 (file)
@@ -481,13 +481,13 @@ PHP_FUNCTION(hash_update_file)
 {
        zval *zhash, *zcontext = NULL;
        php_hashcontext_object *hash;
-       php_stream_context *context;
+       php_stream_context *context = NULL;
        php_stream *stream;
        zend_string *filename;
        char buf[1024];
        ssize_t n;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|r", &zhash, php_hashcontext_ce, &filename, &zcontext) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|r!", &zhash, php_hashcontext_ce, &filename, &zcontext) == FAILURE) {
                RETURN_THROWS();
        }
 
index e83f38b22cbc79d975e0374fddb0007044dbdee8..a634112d00fd8b42463ecc955461ea4b9f546fb7 100644 (file)
@@ -10,7 +10,7 @@ function hash_hmac(string $algo, string $data, string $key, bool $raw_output = f
 
 function hash_hmac_file(string $algo, string $data, string $key, bool $raw_output = false): string|false {}
 
-function hash_init(string $algo, int $options = 0, string $key = UNKNOWN): HashContext {}
+function hash_init(string $algo, int $options = 0, string $key = ""): HashContext {}
 
 function hash_update(HashContext $context, string $data): bool {}
 
@@ -18,7 +18,7 @@ function hash_update(HashContext $context, string $data): bool {}
 function hash_update_stream(HashContext $context, $handle, int $length = -1): int {}
 
 /** @param resource $stream_context */
-function hash_update_file(HashContext $context, string $filename, $stream_context = UNKNOWN): bool {}
+function hash_update_file(HashContext $context, string $filename, $stream_context = null): bool {}
 
 function hash_final(HashContext $context, bool $raw_output = false): string {}
 
index 156c7ad2d276667fdb8eda61eb4c32306d34fbe1..13e95aa03092b4a2270bf31c148f546dd06292a4 100644 (file)
@@ -24,7 +24,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_hash_init, 0, 1, HashContext, 0)
        ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key, IS_STRING, 0, "\"\"")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_update, 0, 2, _IS_BOOL, 0)
@@ -41,7 +41,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_update_file, 0, 2, _IS_BOOL, 0)
        ZEND_ARG_OBJ_INFO(0, context, HashContext, 0)
        ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
-       ZEND_ARG_INFO(0, stream_context)
+       ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, stream_context, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_final, 0, 1, IS_STRING, 0)
index 7cda884a6537573568fa0c761e469a9d109ddcdd..ad427eaf3a7cc9197caaac0f9404a5117511d313 100644 (file)
@@ -1826,20 +1826,22 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset,
    Returns the character count of str */
 PHP_FUNCTION(iconv_strlen)
 {
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0;
+       const char *charset = NULL;
+       size_t charset_len;
        zend_string *str;
 
        php_iconv_err_t err;
 
        size_t retval;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|s",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|s!",
                &str, &charset, &charset_len) == FAILURE) {
                RETURN_THROWS();
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
@@ -1858,8 +1860,8 @@ PHP_FUNCTION(iconv_strlen)
    Returns specified part of a string */
 PHP_FUNCTION(iconv_substr)
 {
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0;
+       const char *charset = NULL;
+       size_t charset_len;
        zend_string *str;
        zend_long offset, length = 0;
        zend_bool len_is_null = 1;
@@ -1868,13 +1870,15 @@ PHP_FUNCTION(iconv_substr)
 
        smart_str retval = {0};
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sl|l!s",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sl|l!s!",
                &str, &offset, &length, &len_is_null,
                &charset, &charset_len) == FAILURE) {
                RETURN_THROWS();
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
@@ -1898,8 +1902,8 @@ PHP_FUNCTION(iconv_substr)
    Finds position of first occurrence of needle within part of haystack beginning with offset */
 PHP_FUNCTION(iconv_strpos)
 {
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0, haystk_len;
+       const char *charset = NULL;
+       size_t charset_len, haystk_len;
        zend_string *haystk;
        zend_string *ndl;
        zend_long offset = 0;
@@ -1908,13 +1912,15 @@ PHP_FUNCTION(iconv_strpos)
 
        size_t retval;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ls",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|ls!",
                &haystk, &ndl,
                &offset, &charset, &charset_len) == FAILURE) {
                RETURN_THROWS();
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
@@ -1953,8 +1959,8 @@ PHP_FUNCTION(iconv_strpos)
    Finds position of last occurrence of needle within part of haystack beginning with offset */
 PHP_FUNCTION(iconv_strrpos)
 {
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0;
+       const char *charset = NULL;
+       size_t charset_len;
        zend_string *haystk;
        zend_string *ndl;
 
@@ -1962,7 +1968,7 @@ PHP_FUNCTION(iconv_strrpos)
 
        size_t retval;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|s",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|s!",
                &haystk, &ndl,
                &charset, &charset_len) == FAILURE) {
                RETURN_THROWS();
@@ -1972,7 +1978,9 @@ PHP_FUNCTION(iconv_strrpos)
                RETURN_FALSE;
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
@@ -2097,21 +2105,23 @@ PHP_FUNCTION(iconv_mime_encode)
 PHP_FUNCTION(iconv_mime_decode)
 {
        zend_string *encoded_str;
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0;
+       const char *charset = NULL;
+       size_t charset_len;
        zend_long mode = 0;
 
        smart_str retval = {0};
 
        php_iconv_err_t err;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ls",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ls!",
                &encoded_str, &mode, &charset, &charset_len) == FAILURE) {
 
                RETURN_THROWS();
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
@@ -2137,21 +2147,23 @@ PHP_FUNCTION(iconv_mime_decode)
 PHP_FUNCTION(iconv_mime_decode_headers)
 {
        zend_string *encoded_str;
-       const char *charset = get_internal_encoding();
-       size_t charset_len = 0;
+       const char *charset = NULL;
+       size_t charset_len;
        zend_long mode = 0;
        char *enc_str_tmp;
        size_t enc_str_len_tmp;
 
        php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ls",
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|ls!",
                &encoded_str, &mode, &charset, &charset_len) == FAILURE) {
 
                RETURN_THROWS();
        }
 
-       if (charset_len >= ICONV_CSNMAXLEN) {
+       if (charset == NULL) {
+               charset = get_internal_encoding();
+       } else if (charset_len >= ICONV_CSNMAXLEN) {
                php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
                RETURN_FALSE;
        }
index ae2a0fa0cbf4961f287e342413575aba852ac152..a5f6743e81c44074ccd77d675d65d7d39b9beafd 100644 (file)
@@ -2,22 +2,22 @@
 
 /** @generate-function-entries */
 
-function iconv_strlen(string $str, string $charset = UNKNOWN): int|false {}
+function iconv_strlen(string $str, ?string $charset = null): int|false {}
 
-function iconv_substr(string $str, int $offset, ?int $length = null, string $charset = UNKNOWN): string|false {}
+function iconv_substr(string $str, int $offset, ?int $length = null, ?string $charset = null): string|false {}
 
-function iconv_strpos(string $haystack, string $needle, int $offset = 0, string $charset = UNKNOWN): int|false {}
+function iconv_strpos(string $haystack, string $needle, int $offset = 0, ?string $charset = null): int|false {}
 
-function iconv_strrpos(string $haystack, string $needle, string $charset = UNKNOWN): int|false {}
+function iconv_strrpos(string $haystack, string $needle, ?string $charset = null): int|false {}
 
 function iconv_mime_encode(string $field_name, string $field_value, array $preference = []): string|false {}
 
-function iconv_mime_decode(string $encoded_string, int $mode = 0, string $charset = UNKNOWN): string|false {}
+function iconv_mime_decode(string $encoded_string, int $mode = 0, ?string $charset = null): string|false {}
 
-function iconv_mime_decode_headers(string $headers, int $mode = 0, string $charset = UNKNOWN): array|false {}
+function iconv_mime_decode_headers(string $headers, int $mode = 0, ?string $charset = null): array|false {}
 
 function iconv(string $in_charset, string $out_charset, string $str): string|false {}
 
 function iconv_set_encoding(string $type, string $charset): bool {}
 
-function iconv_get_encoding(string $type = 'all'): array|string|false {}
+function iconv_get_encoding(string $type = "all"): array|string|false {}
index f182521ebedf00e23c8edc5006b48e158c9f06d9..8c50c2332b6085ed919419840842f689032afd35 100644 (file)
@@ -2,27 +2,27 @@
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strlen, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_substr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_strrpos, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, needle, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_encode, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
@@ -34,13 +34,13 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, encoded_string, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_mime_decode_headers, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO(0, headers, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
@@ -55,7 +55,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_iconv_set_encoding, 0, 2, _IS_BO
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_iconv_get_encoding, 0, 0, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 0, "\'all\'")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 0, "\"all\"")
 ZEND_END_ARG_INFO()
 
 
index f015c71d2452d0c22f6cbed73d77ef0cddf0f8b7..febc5eca2daaf2376cbb58918d287a4b8abdf039 100644 (file)
@@ -913,11 +913,11 @@ PHP_FUNCTION(libxml_set_streams_context)
 PHP_FUNCTION(libxml_use_internal_errors)
 {
        xmlStructuredErrorFunc current_handler;
-       zend_bool use_errors=0, retval;
+       zend_bool use_errors, use_errors_is_null = 1, retval;
 
        ZEND_PARSE_PARAMETERS_START(0, 1)
                Z_PARAM_OPTIONAL
-               Z_PARAM_BOOL(use_errors)
+               Z_PARAM_BOOL_OR_NULL(use_errors, use_errors_is_null)
        ZEND_PARSE_PARAMETERS_END();
 
        current_handler = xmlStructuredError;
@@ -927,7 +927,7 @@ PHP_FUNCTION(libxml_use_internal_errors)
                retval = 0;
        }
 
-       if (ZEND_NUM_ARGS() == 0) {
+       if (use_errors_is_null) {
                RETURN_BOOL(retval);
        }
 
index 729b91a2ec41fed6004ec402adba6c52763b334a..74a15e916994e69bb5f51a3f45381d7f0fe29c93 100644 (file)
@@ -5,7 +5,7 @@
 /** @param resource $context */
 function libxml_set_streams_context($context): void {}
 
-function libxml_use_internal_errors(bool $use_errors = UNKNOWN): bool {}
+function libxml_use_internal_errors(?bool $use_errors = null): bool {}
 
 function libxml_get_last_error(): LibXMLError|false {}
 
index 3b11e1a5543479375292b5cb704c92bd32860898..5d28e7df7e57ce5575babf90bbdbce0193b871a9 100644 (file)
@@ -5,7 +5,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_libxml_set_streams_context, 0, 1
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_libxml_use_internal_errors, 0, 0, _IS_BOOL, 0)
-       ZEND_ARG_TYPE_INFO(0, use_errors, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_errors, _IS_BOOL, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_libxml_get_last_error, 0, 0, LibXMLError, MAY_BE_FALSE)
index 7509b04c88191d8ffc62ffbd63edc60bbeec6a98..17452bf287688af8f9e626c4ce6373cacd8b710b 100644 (file)
@@ -1003,36 +1003,19 @@ PHP_FUNCTION(mysqli_stmt_construct)
        zval                            *mysql_link;
        MY_STMT                         *stmt;
        MYSQLI_RESOURCE         *mysqli_resource;
-       char                            *statement;
+       char                            *statement = NULL;
        size_t                                  statement_len;
 
-       switch (ZEND_NUM_ARGS())
-       {
-               case 1:  /* mysql_stmt_init */
-                       if (zend_parse_parameters(1, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) {
-                               RETURN_THROWS();
-                       }
-                       MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
-
-                       stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
-
-                       stmt->stmt = mysql_stmt_init(mysql->mysql);
-               break;
-               case 2:
-                       if (zend_parse_parameters(2, "Os", &mysql_link, mysqli_link_class_entry, &statement, &statement_len)==FAILURE) {
-                               RETURN_THROWS();
-                       }
-                       MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!", &mysql_link, mysqli_link_class_entry, &statement, &statement_len) == FAILURE) {
+               RETURN_THROWS();
+       }
 
-                       stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
+       MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
 
-                       if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
-                               mysql_stmt_prepare(stmt->stmt, (char *)statement, statement_len);
-                       }
-               break;
-               default:
-                       WRONG_PARAM_COUNT;
-               break;
+       stmt = (MY_STMT *) ecalloc(1, sizeof(MY_STMT));
+       stmt->stmt = mysql_stmt_init(mysql->mysql);
+       if (stmt->stmt && statement) {
+               mysql_stmt_prepare(stmt->stmt, (char *)statement, statement_len);
        }
 
        if (!stmt->stmt) {
index 5d8a75148ddaeb497c0526c28bc4a19267ab093d..0bf9fb2bf19da45a819b92272a0c9c9f1d34eb79 100644 (file)
@@ -28,7 +28,7 @@ class mysqli
      * @return bool
      * @alias mysqli_begin_transaction
      */
-    public function begin_transaction(int $flags = 0, string $name = UNKNOWN) {}
+    public function begin_transaction(int $flags = 0, ?string $name = null) {}
 
     /**
      * @return bool
@@ -52,7 +52,7 @@ class mysqli
      * @return bool
      * @alias mysqli_commit
      */
-    public function commit(int $flags = -1, string $name = UNKNOWN) {}
+    public function commit(int $flags = -1, ?string $name = null) {}
 
     /**
      * @return mysqli|null|false
@@ -217,7 +217,7 @@ class mysqli
      * @return bool
      * @alias mysqli_rollback
      */
-    public function rollback(int $flags = 0, string $name = '') {}
+    public function rollback(int $flags = 0, ?string $name = null) {}
 
     /**
      * @return bool
@@ -389,7 +389,7 @@ class mysqli_result
 class mysqli_stmt
 {
     /** @alias mysqli_stmt_construct */
-    public function __construct(mysqli $mysqli_link, string $statement = UNKNOWN) {}
+    public function __construct(mysqli $mysqli_link, ?string $statement = null) {}
 
     /**
      * @return int|false
@@ -526,7 +526,7 @@ function mysqli_affected_rows(mysqli $mysql_link): int|string {}
 
 function mysqli_autocommit(mysqli $mysql_link, bool $mode): bool {}
 
-function mysqli_begin_transaction(mysqli $mysql_link, int $flags = 0, string $name = UNKNOWN): bool {}
+function mysqli_begin_transaction(mysqli $mysql_link, int $flags = 0, ?string $name = null): bool {}
 
 function mysqli_change_user(mysqli $mysql_link, string $user, string $password, ?string $database): bool {}
 
@@ -534,7 +534,7 @@ function mysqli_character_set_name(mysqli $mysql_link): ?string {}
 
 function mysqli_close(mysqli $mysql_link): bool {}
 
-function mysqli_commit(mysqli $mysql_link, int $flags = -1, string $name = UNKNOWN): bool {}
+function mysqli_commit(mysqli $mysql_link, int $flags = -1, ?string $name = null): bool {}
 
 function mysqli_connect(
     ?string $host = null,
@@ -668,7 +668,7 @@ function mysqli_reap_async_query(mysqli $mysqli_link): mysqli_result|bool {}
 
 function mysqli_release_savepoint(mysqli $mysqli_link, string $name): bool {}
 
-function mysqli_rollback(mysqli $mysqli_link, int $flags = 0, string $name = ''): bool {}
+function mysqli_rollback(mysqli $mysqli_link, int $flags = 0, ?string $name = null): bool {}
 
 function mysqli_savepoint(mysqli $mysqli_link, string $name): bool {}
 
index 3e7bbcb11c3fd59b4791486dff583ce04c4e4c80..f391cd6234d49044e728c0e9165f4fb7d7bbfeaa 100644 (file)
@@ -738,9 +738,9 @@ PHP_FUNCTION(mysqli_commit)
        zval            *mysql_link;
        zend_long               flags = TRANS_COR_NO_OPT;
        char *          name = NULL;
-       size_t                  name_len = 0;
+       size_t                  name_len;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
                RETURN_THROWS();
        }
        MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
@@ -1981,7 +1981,7 @@ PHP_FUNCTION(mysqli_rollback)
        char *          name = NULL;
        size_t                  name_len = 0;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
                RETURN_THROWS();
        }
        MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
index bbc489f6be2083a3eb76e06e54bbc21897c50eda..80c5fcd7cb150f74815e5eba0d2841c38ff48185 100644 (file)
@@ -12,7 +12,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_begin_transaction, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_OBJ_INFO(0, mysql_link, mysqli, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_change_user, 0, 4, _IS_BOOL, 0)
@@ -33,7 +33,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_commit, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_OBJ_INFO(0, mysql_link, mysqli, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "-1")
-       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_mysqli_connect, 0, 0, mysqli, MAY_BE_NULL|MAY_BE_FALSE)
@@ -265,7 +265,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mysqli_rollback, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_OBJ_INFO(0, mysqli_link, mysqli, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 0, "\'\'")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 #define arginfo_mysqli_savepoint arginfo_mysqli_release_savepoint
@@ -431,7 +431,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_begin_transaction, 0, 0, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_change_user, 0, 0, 3)
@@ -447,7 +447,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_commit, 0, 0, 0)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "-1")
-       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 #define arginfo_class_mysqli_connect arginfo_class_mysqli___construct
@@ -530,10 +530,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_release_savepoint, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_rollback, 0, 0, 0)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 0, "\'\'")
-ZEND_END_ARG_INFO()
+#define arginfo_class_mysqli_rollback arginfo_class_mysqli_begin_transaction
 
 #define arginfo_class_mysqli_savepoint arginfo_class_mysqli_release_savepoint
 
@@ -622,7 +619,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_stmt___construct, 0, 0, 1)
        ZEND_ARG_OBJ_INFO(0, mysqli_link, mysqli, 0)
-       ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, statement, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_stmt_attr_get, 0, 0, 1)
index 97d648dc2f14a37aa22ca21ecc6e10b771b8ee94..bc6cafb69b75b1702d0598b2cbe9172aa95289eb 100644 (file)
@@ -1176,7 +1176,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
        size_t                  name_len = -1;
        zend_bool       err = FALSE;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
                RETURN_THROWS();
        }
        MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);