summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-05-02 15:25:25 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-05-05 19:08:20 +0200
commit3ebce8e9fc10b97ad46ce88268f5b96e7e1be8ac (patch)
tree62e899506211ed94817a3c888c55e76b959c1432
parent5bc1e224dbd660cea99c222baf8bd3c215d25073 (diff)
downloadphp-git-3ebce8e9fc10b97ad46ce88268f5b96e7e1be8ac.tar.gz
Fix UNKNOWN default values in various extensions
Closes GH-5514
-rw-r--r--Zend/zend_API.h6
-rw-r--r--ext/dom/php_dom.stub.php7
-rw-r--r--ext/dom/php_dom_arginfo.h4
-rw-r--r--ext/enchant/enchant.c2
-rw-r--r--ext/enchant/enchant.stub.php2
-rw-r--r--ext/enchant/enchant_arginfo.h2
-rw-r--r--ext/ffi/ffi.c4
-rw-r--r--ext/ffi/ffi.stub.php2
-rw-r--r--ext/ffi/ffi_arginfo.h4
-rw-r--r--ext/ftp/ftp.stub.php2
-rw-r--r--ext/ftp/ftp_arginfo.h2
-rw-r--r--ext/hash/hash.c4
-rw-r--r--ext/hash/hash.stub.php4
-rw-r--r--ext/hash/hash_arginfo.h4
-rw-r--r--ext/iconv/iconv.c60
-rw-r--r--ext/iconv/iconv.stub.php14
-rw-r--r--ext/iconv/iconv_arginfo.h14
-rw-r--r--ext/libxml/libxml.c6
-rw-r--r--ext/libxml/libxml.stub.php2
-rw-r--r--ext/libxml/libxml_arginfo.h2
-rw-r--r--ext/mysqli/mysqli.c35
-rw-r--r--ext/mysqli/mysqli.stub.php14
-rw-r--r--ext/mysqli/mysqli_api.c6
-rw-r--r--ext/mysqli/mysqli_arginfo.h17
-rw-r--r--ext/mysqli/mysqli_nonapi.c2
25 files changed, 109 insertions, 112 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 0e361ad7c5..f97f54af44 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -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); \
diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php
index 8f1b375471..3d77b136c7 100644
--- a/ext/dom/php_dom.stub.php
+++ b/ext/dom/php_dom.stub.php
@@ -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) {}
diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h
index e989301311..c7fd0c81df 100644
--- a/ext/dom/php_dom_arginfo.h
+++ b/ext/dom/php_dom_arginfo.h
@@ -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
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index 0195555379..1c43323f95 100644
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -656,9 +656,9 @@ PHP_FUNCTION(enchant_dict_quick_check)
enchant_dict_free_string_list(pdict->pdict, suggs);
}
-
RETURN_FALSE;
}
+
RETURN_TRUE;
}
/* }}} */
diff --git a/ext/enchant/enchant.stub.php b/ext/enchant/enchant.stub.php
index cad28b9103..f235ff59ba 100644
--- a/ext/enchant/enchant.stub.php
+++ b/ext/enchant/enchant.stub.php
@@ -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 {}
diff --git a/ext/enchant/enchant_arginfo.h b/ext/enchant/enchant_arginfo.h
index 967bdfcf72..b0906d9a3d 100644
--- a/ext/enchant/enchant_arginfo.h
+++ b/ext/enchant/enchant_arginfo.h
@@ -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)
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 1ca8a9be75..7784c7b389 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -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;
diff --git a/ext/ffi/ffi.stub.php b/ext/ffi/ffi.stub.php
index a45235469e..89d1890e61 100644
--- a/ext/ffi/ffi.stub.php
+++ b/ext/ffi/ffi.stub.php
@@ -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 {}
diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h
index 009512fe82..8bd12b0998 100644
--- a/ext/ffi/ffi_arginfo.h
+++ b/ext/ffi/ffi_arginfo.h
@@ -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)
diff --git a/ext/ftp/ftp.stub.php b/ext/ftp/ftp.stub.php
index 72b7126843..b293c453fa 100644
--- a/ext/ftp/ftp.stub.php
+++ b/ext/ftp/ftp.stub.php
@@ -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 {}
diff --git a/ext/ftp/ftp_arginfo.h b/ext/ftp/ftp_arginfo.h
index 83e7b672f4..738f8e9284 100644
--- a/ext/ftp/ftp_arginfo.h
+++ b/ext/ftp/ftp_arginfo.h
@@ -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)
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 25c816d47a..31ead37163 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -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();
}
diff --git a/ext/hash/hash.stub.php b/ext/hash/hash.stub.php
index e83f38b22c..a634112d00 100644
--- a/ext/hash/hash.stub.php
+++ b/ext/hash/hash.stub.php
@@ -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 {}
diff --git a/ext/hash/hash_arginfo.h b/ext/hash/hash_arginfo.h
index 156c7ad2d2..13e95aa030 100644
--- a/ext/hash/hash_arginfo.h
+++ b/ext/hash/hash_arginfo.h
@@ -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)
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 7cda884a65..ad427eaf3a 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -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;
}
diff --git a/ext/iconv/iconv.stub.php b/ext/iconv/iconv.stub.php
index ae2a0fa0cb..a5f6743e81 100644
--- a/ext/iconv/iconv.stub.php
+++ b/ext/iconv/iconv.stub.php
@@ -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 {}
diff --git a/ext/iconv/iconv_arginfo.h b/ext/iconv/iconv_arginfo.h
index f182521ebe..8c50c2332b 100644
--- a/ext/iconv/iconv_arginfo.h
+++ b/ext/iconv/iconv_arginfo.h
@@ -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()
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index f015c71d24..febc5eca2d 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -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);
}
diff --git a/ext/libxml/libxml.stub.php b/ext/libxml/libxml.stub.php
index 729b91a2ec..74a15e9169 100644
--- a/ext/libxml/libxml.stub.php
+++ b/ext/libxml/libxml.stub.php
@@ -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 {}
diff --git a/ext/libxml/libxml_arginfo.h b/ext/libxml/libxml_arginfo.h
index 3b11e1a554..5d28e7df7e 100644
--- a/ext/libxml/libxml_arginfo.h
+++ b/ext/libxml/libxml_arginfo.h
@@ -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)
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 7509b04c88..17452bf287 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -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) {
diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php
index 5d8a75148d..0bf9fb2bf1 100644
--- a/ext/mysqli/mysqli.stub.php
+++ b/ext/mysqli/mysqli.stub.php
@@ -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 {}
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 3e7bbcb11c..f391cd6234 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -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);
diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h
index bbc489f6be..80c5fcd7cb 100644
--- a/ext/mysqli/mysqli_arginfo.h
+++ b/ext/mysqli/mysqli_arginfo.h
@@ -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)
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 97d648dc2f..bc6cafb69b 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -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);