diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-08-21 00:42:44 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-09-07 18:58:11 +0200 |
commit | 2c96780e1c10c3c851608835411e21879a069199 (patch) | |
tree | 56d8f9168d9ad60a89cad1598e0498230a1d4e1e /ext | |
parent | a249980006477ee48b44fa26a3b3d48c4c24633c (diff) | |
download | php-git-2c96780e1c10c3c851608835411e21879a069199.tar.gz |
Fix UNKNOWN default values in ext/standard
Closes GH-6026
Diffstat (limited to 'ext')
25 files changed, 270 insertions, 249 deletions
diff --git a/ext/bz2/bz2.stub.php b/ext/bz2/bz2.stub.php index 2d47c04501..1f8b011059 100644 --- a/ext/bz2/bz2.stub.php +++ b/ext/bz2/bz2.stub.php @@ -15,7 +15,7 @@ function bzread($bz, int $length = 1024): string|false {} * @param resource $bz * @alias fwrite */ -function bzwrite($bz, string $str, int $length = UNKNOWN): int|false {} +function bzwrite($bz, string $str, ?int $length = null): int|false {} /** * @param resource $bz diff --git a/ext/bz2/bz2_arginfo.h b/ext/bz2/bz2_arginfo.h index 322aaf7215..902553002e 100644 --- a/ext/bz2/bz2_arginfo.h +++ b/ext/bz2/bz2_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: a5c534b7cd92619dfa0fdf29bd0a94fcda27f089 */ + * Stub hash: 9bcd75ddbde225e65ee9f00d86d16677d671b4e4 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_bzopen, 0, 0, 2) ZEND_ARG_INFO(0, file) @@ -14,7 +14,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bzwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_INFO(0, bz) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bzflush, 0, 1, _IS_BOOL, 0) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6ff4c3d573..922bcab330 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -739,7 +739,7 @@ PHP_FUNCTION(getenv) ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING(str, str_len) + Z_PARAM_STRING_OR_NULL(str, str_len) Z_PARAM_BOOL(local_only) ZEND_PARSE_PARAMETERS_END(); @@ -1429,22 +1429,17 @@ PHP_FUNCTION(error_log) { char *message, *opt = NULL, *headers = NULL; size_t message_len, opt_len = 0, headers_len = 0; - int opt_err = 0, argc = ZEND_NUM_ARGS(); zend_long erropt = 0; ZEND_PARSE_PARAMETERS_START(1, 4) Z_PARAM_STRING(message, message_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(erropt) - Z_PARAM_PATH(opt, opt_len) - Z_PARAM_STRING(headers, headers_len) + Z_PARAM_PATH_OR_NULL(opt, opt_len) + Z_PARAM_STRING_OR_NULL(headers, headers_len) ZEND_PARSE_PARAMETERS_END(); - if (argc > 1) { - opt_err = (int)erropt; - } - - if (_php_error_log_ex(opt_err, message, message_len, opt, headers) == FAILURE) { + if (_php_error_log_ex((int) erropt, message, message_len, opt, headers) == FAILURE) { RETURN_FALSE; } @@ -2270,16 +2265,17 @@ PHP_FUNCTION(connection_status) PHP_FUNCTION(ignore_user_abort) { zend_bool arg = 0; + zend_bool arg_is_null = 1; int old_setting; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(arg) + Z_PARAM_BOOL_OR_NULL(arg, arg_is_null) ZEND_PARSE_PARAMETERS_END(); old_setting = (unsigned short)PG(ignore_user_abort); - if (ZEND_NUM_ARGS()) { + if (!arg_is_null) { zend_string *key = zend_string_init("ignore_user_abort", sizeof("ignore_user_abort") - 1, 0); zend_alter_ini_entry_chars(key, arg ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 44eb05a015..9352b9712c 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -271,7 +271,7 @@ function ip2long(string $ip_address): int|false {} function long2ip(int $proper_address): string|false {} -function getenv(string $variable = UNKNOWN, bool $local_only = false): string|array|false {} +function getenv(?string $variable = null, bool $local_only = false): string|array|false {} #ifdef HAVE_PUTENV function putenv(string $setting): bool {} @@ -296,7 +296,7 @@ function get_current_user(): string {} function get_cfg_var(string $option_name): string|array|false {} -function error_log(string $message, int $message_type = 0, string $destination = UNKNOWN, string $extra_headers = UNKNOWN): bool {} +function error_log(string $message, int $message_type = 0, ?string $destination = null, ?string $extra_headers = null): bool {} function error_get_last(): ?array {} @@ -343,7 +343,7 @@ function connection_aborted(): int {} function connection_status(): int {} -function ignore_user_abort(bool $value = UNKNOWN): int {} +function ignore_user_abort(?bool $value = null): int {} #if HAVE_GETSERVBYNAME function getservbyname(string $service, string $protocol): int|false {} @@ -504,7 +504,7 @@ function metaphone(string $text, int $phones = 0): string|false {} /* {{{ head.c */ function header(string $string, bool $replace = true, int $http_response_code = 0): void {} -function header_remove(string $name = UNKNOWN): void {} +function header_remove(?string $name = null): void {} /** @param array|int $expires_or_options */ function setrawcookie(string $name, string $value = '', $expires_or_options = 0, string $path = '', string $domain = '', bool $secure = false, bool $httponly = false): bool {} @@ -528,7 +528,7 @@ function htmlspecialchars(string $string, int $quote_style = ENT_COMPAT, ?string function htmlspecialchars_decode(string $string, int $quote_style = ENT_COMPAT): string|false {} -function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, string $encoding = UNKNOWN): string|false {} +function html_entity_decode(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null): string|false {} function htmlentities(string $string, int $quote_style = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string {} @@ -549,9 +549,9 @@ function bin2hex(string $data): string {} function hex2bin(string $data): string|false {} -function strspn(string $str, string $mask, int $start = 0, int $len = UNKNOWN): int|false {} +function strspn(string $str, string $mask, int $start = 0, ?int $len = null): int|false {} -function strcspn(string $str, string $mask, int $start = 0, int $len = UNKNOWN): int|false {} +function strcspn(string $str, string $mask, int $start = 0, ?int $len = null): int|false {} #if HAVE_NL_LANGINFO function nl_langinfo(int $item): string|false {} @@ -572,12 +572,12 @@ function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut function explode(string $separator, string $str, int $limit = PHP_INT_MAX): array {} -function implode(string|array $glue, array $pieces = UNKNOWN): string {} +function implode(string|array $glue, ?array $pieces = null): string {} /** @alias implode */ -function join(string|array $glue, array $pieces = UNKNOWN): string {} +function join(string|array $glue, ?array $pieces = null): string {} -function strtok(string $str, string $token = UNKNOWN): string|false {} +function strtok(string $str, ?string $token = null): string|false {} function strtoupper(string $str): string {} @@ -587,7 +587,7 @@ function basename(string $path, string $suffix = ""): string {} function dirname(string $path, int $levels = 1): string {} -function pathinfo(string $path, int $options = UNKNOWN): array|string {} +function pathinfo(string $path, int $options = PATHINFO_ALL): array|string {} function stristr(string $haystack, string $needle, bool $before_needle = false): string|false {} @@ -617,10 +617,10 @@ function chunk_split(string $str, int $chunklen = 76, string $ending = "\r\n"): function substr(string $str, int $start, ?int $length = null): string|false {} /** - * @param mixed $start - * @param mixed $length + * @param array|int $start + * @param array|int|null $length */ -function substr_replace(array|string $str, string|array $replace, $start, $length = UNKNOWN): string|array|false {} +function substr_replace(array|string $str, string|array $replace, $start, $length = null): string|array|false {} function quotemeta(string $str): string {} @@ -634,7 +634,7 @@ function lcfirst(string $str): string {} function ucwords(string $str, string $delimiters = " \t\r\n\f\v"): string {} -function strtr(string $str, string|array $from, string $to = UNKNOWN): string {} +function strtr(string $str, string|array $from, ?string $to = null): string {} function strrev(string $str): string {} @@ -650,17 +650,16 @@ function stripcslashes(string $str): string {} function stripslashes(string $str): string {} /** @param int $replace_count */ -function str_replace(array|string $search, array|string $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {} +function str_replace(array|string $search, array|string $replace, string|array $subject, &$replace_count = null): string|array {} /** @param int $replace_count */ -function str_ireplace(array|string $search, array|string $replace, string|array $subject, &$replace_count = UNKNOWN): string|array {} +function str_ireplace(array|string $search, array|string $replace, string|array $subject, &$replace_count = null): string|array {} function hebrev(string $str, int $max_chars_per_line = 0): string {} function nl2br(string $str, bool $is_xhtml = true): string {} -/** @param array|string|null $allowable_tags */ -function strip_tags(string $str, $allowable_tags = UNKNOWN): string {} +function strip_tags(string $str, array|string|null $allowable_tags = null): string {} /** * @param array|string $locales @@ -693,7 +692,7 @@ function str_rot13(string $str): string {} function str_shuffle(string $str): string {} -function str_word_count(string $str, int $format = 0, string $charlist = UNKNOWN): array|int {} +function str_word_count(string $str, int $format = 0, ?string $charlist = null): array|int {} function str_split(string $str, int $split_length = 1): array {} @@ -706,22 +705,22 @@ function utf8_encode(string $data): string {} function utf8_decode(string $data): string {} /** - * @param resource $context + * @param resource|null $context * @return resource|false */ -function opendir(string $path, $context = UNKNOWN) {} +function opendir(string $path, $context = null) {} /** @param resource $context */ -function getdir(string $path, $context = UNKNOWN): Directory|false {} +function getdir(string $path, $context = null): Directory|false {} /** - * @param resource $context + * @param resource|null $context * @alias getdir */ -function dir(string $path, $context = UNKNOWN): Directory|false {} +function dir(string $path, $context = null): Directory|false {} -/** @param resource $dir_handle */ -function closedir($dir_handle = UNKNOWN): void {} +/** @param resource|null $dir_handle */ +function closedir($dir_handle = null): void {} function chdir(string $directory): bool {} @@ -731,14 +730,14 @@ function chroot(string $directory): bool {} function getcwd(): string|false {} -/** @param resource $dir_handle */ -function rewinddir($dir_handle = UNKNOWN): void {} +/** @param resource|null $dir_handle */ +function rewinddir($dir_handle = null): void {} -/** @param resource $dir_handle */ -function readdir($dir_handle = UNKNOWN): string|false {} +/** @param resource|null $dir_handle */ +function readdir($dir_handle = null): string|false {} -/** @param resource $context */ -function scandir(string $directory, int $sorting_order = 0, $context = UNKNOWN): array|false {} +/** @param resource|null $context */ +function scandir(string $directory, int $sorting_order = 0, $context = null): array|false {} #ifdef HAVE_GLOB function glob(string $pattern, int $flags = 0): array|false {} @@ -793,7 +792,7 @@ function rewind($handle): bool {} /** @param resource|null $context */ function rmdir(string $dirname, $context = null): bool {} -function umask(int $mask = UNKNOWN): int {} +function umask(?int $mask = null): int {} /** @param resource $handle */ function fclose($handle): bool {} @@ -805,7 +804,7 @@ function feof($handle): bool {} function fgetc($handle): string|false {} /** @param resource $handle */ -function fgets($handle, int $length = UNKNOWN): string|false {} +function fgets($handle, ?int $length = null): string|false {} /** @param resource $handle */ function fread($handle, int $length): string|false {} @@ -838,13 +837,13 @@ function ftell($handle): int|false {} function fflush($handle): bool {} /** @param resource $handle */ -function fwrite($handle, string $content, int $max_length = UNKNOWN): int|false {} +function fwrite($handle, string $content, ?int $max_length = null): int|false {} /** * @param resource $handle * @alias fwrite */ -function fputs($handle, string $content, int $max_length = UNKNOWN): int|false {} +function fputs($handle, string $content, ?int $max_length = null): int|false {} /** @param resource|null $context */ function mkdir(string $pathname, int $mode = 0777, bool $recursive = false, $context = null): bool {} @@ -940,7 +939,7 @@ function lchgrp(string $filename, string|int $group): bool {} function chmod(string $filename, int $mode): bool {} #if HAVE_UTIME -function touch(string $filename, int $time = UNKNOWN, int $atime = UNKNOWN): bool {} +function touch(string $filename, ?int $time = null, ?int $atime = null): bool {} #endif function clearstatcache(bool $clear_realpath_cache = false, string $filename = ""): void {} @@ -979,14 +978,14 @@ function vfprintf($handle, string $format, array $args): int {} * @param string $errstr * @return resource|false */ -function fsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, float $timeout = UNKNOWN) {} +function fsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, ?float $timeout = null) {} /** * @param int $errno * @param string $errstr * @return resource|false */ -function pfsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, float $timeout = UNKNOWN) {} +function pfsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, ?float $timeout = null) {} /* http.c */ @@ -1008,7 +1007,7 @@ function getimagesizefromstring(string $image, &$image_info = null): array|false function phpinfo(int $what = INFO_ALL): bool {} -function phpversion(string $extension = UNKNOWN): string|false {} +function phpversion(?string $extension = null): string|false {} function phpcredits(int $flag = CREDITS_ALL): bool {} @@ -1044,7 +1043,7 @@ function link(string $target, string $link): bool {} /* mail.c */ -function mail(string $to, string $subject, string $message, string|array $additional_headers = UNKNOWN, string $additional_parameters = ""): bool {} +function mail(string $to, string $subject, string $message, array|string $additional_headers = [], string $additional_parameters = ""): bool {} /* math.c */ @@ -1233,24 +1232,22 @@ function stream_context_set_option($context, array|string $wrapper_or_options, ? function stream_context_get_options($stream_or_context): array {} /** @return resource */ -function stream_context_get_default(array $options = UNKNOWN) {} +function stream_context_get_default(?array $options = null) {} /** @return resource */ function stream_context_set_default(array $options) {} /** * @param resource $stream - * @param mixed $params * @return resource|false */ -function stream_filter_prepend($stream, string $filtername, int $read_write = 0, $params = UNKNOWN) {} +function stream_filter_prepend($stream, string $filtername, int $read_write = 0, mixed $params = UNKNOWN) {} /** * @param resource $stream - * @param mixed $params * @return resource|false */ -function stream_filter_append($stream, string $filtername, int $read_write = 0, $params = UNKNOWN) {} +function stream_filter_append($stream, string $filtername, int $read_write = 0, mixed $params = UNKNOWN) {} /** @param resource $stream_filter */ function stream_filter_remove($stream_filter): bool {} @@ -1261,7 +1258,7 @@ function stream_filter_remove($stream_filter): bool {} * @param resource|null $context * @return resource|false */ -function stream_socket_client(string $remote_socket, &$errno = null, &$errstr = null, float $timeout = UNKNOWN, int $flags = STREAM_CLIENT_CONNECT, $context = null) {} +function stream_socket_client(string $remote_socket, &$errno = null, &$errstr = null, ?float $timeout = null, int $flags = STREAM_CLIENT_CONNECT, $context = null) {} /** * @param int $errno @@ -1277,7 +1274,7 @@ function stream_socket_server(string $local_socket, &$errno = null, &$errstr = n * @param string $peername * @return resource|false */ -function stream_socket_accept($server_socket, float $timeout = UNKNOWN, &$peername = null) {} +function stream_socket_accept($server_socket, ?float $timeout = null, &$peername = null) {} /** @param resource $handle */ function stream_socket_get_name($handle, bool $want_peer): string|false {} @@ -1310,10 +1307,10 @@ function stream_socket_pair(int $domain, int $type, int $protocol): array|false * @param resource $source * @param resource $dest */ -function stream_copy_to_stream($source, $dest, int $maxlength = UNKNOWN, int $position = 0): int|false {} +function stream_copy_to_stream($source, $dest, ?int $maxlength = null, int $position = 0): int|false {} /** @param resource $handle */ -function stream_get_contents($handle, int $maxlength = UNKNOWN, int $position = -1): string|false {} +function stream_get_contents($handle, ?int $maxlength = null, int $position = -1): string|false {} /** @param resource $stream */ function stream_supports_lock($stream): bool {} @@ -1498,14 +1495,14 @@ function memory_get_peak_usage(bool $real_usage = false): int {} /* versioning.c */ -function version_compare(string $version1, string $version2, string $operator = UNKNOWN): int|bool {} +function version_compare(string $version1, string $version2, ?string $operator = null): int|bool {} /* win32/codepage.c */ #ifdef PHP_WIN32 function sapi_windows_cp_set(int $cp): bool {} -function sapi_windows_cp_get(string $kind = UNKNOWN): int {} +function sapi_windows_cp_get(string $kind = ""): int {} function sapi_windows_cp_conv(int|string $in_codepage, int|string $out_codepage, string $subject): ?string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index ef031e7afb..61a92dc185 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 28da5d6df91403aad82b5872453053dc41076a6a */ + * Stub hash: c51ad7a5f254f8d28f2b2c0b46e214c44f0f96cf */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -389,7 +389,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_long2ip, 0, 1, MAY_BE_STRING|MAY ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_getenv, 0, 0, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, variable, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, variable, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, local_only, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -439,8 +439,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_log, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, message_type, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO(0, destination, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, extra_headers, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extra_headers, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_get_last, 0, 0, IS_ARRAY, 1) @@ -519,7 +519,7 @@ ZEND_END_ARG_INFO() #define arginfo_connection_status arginfo_ob_get_level ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ignore_user_abort, 0, 0, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, _IS_BOOL, 1, "null") ZEND_END_ARG_INFO() #if HAVE_GETSERVBYNAME @@ -744,7 +744,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_header, 0, 1, IS_VOID, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_header_remove, 0, 0, IS_VOID, 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_setrawcookie, 0, 1, _IS_BOOL, 0) @@ -785,7 +785,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_html_entity_decode, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, quote_style, IS_LONG, 0, "ENT_COMPAT") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_htmlentities arginfo_htmlspecialchars @@ -818,7 +818,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strspn, 0, 2, MAY_BE_LONG|MAY_BE ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, mask, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, len, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #define arginfo_strcspn arginfo_strspn @@ -860,14 +860,14 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_implode, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, glue, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, pieces, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pieces, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() #define arginfo_join arginfo_implode ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtok, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, token, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, token, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_strtoupper arginfo_base64_encode @@ -886,7 +886,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pathinfo, 0, 1, MAY_BE_ARRAY|MAY_BE_STRING) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "PATHINFO_ALL") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stristr, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) @@ -941,7 +941,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_substr_replace, 0, 3, MAY_BE_STR ZEND_ARG_TYPE_MASK(0, str, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_MASK(0, replace, MAY_BE_STRING|MAY_BE_ARRAY, NULL) ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, length) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, length, "null") ZEND_END_ARG_INFO() #define arginfo_quotemeta arginfo_base64_encode @@ -966,7 +966,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strtr, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, from, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, to, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_strrev arginfo_base64_encode @@ -992,7 +992,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_replace, 0, 3, MAY_BE_STRING ZEND_ARG_TYPE_MASK(0, search, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_MASK(0, replace, MAY_BE_ARRAY|MAY_BE_STRING, NULL) ZEND_ARG_TYPE_MASK(0, subject, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_INFO(1, replace_count) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, replace_count, "null") ZEND_END_ARG_INFO() #define arginfo_str_ireplace arginfo_str_replace @@ -1009,7 +1009,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_strip_tags, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_INFO(0, allowable_tags) + ZEND_ARG_TYPE_MASK(0, allowable_tags, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_setlocale, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) @@ -1076,7 +1076,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_str_word_count, 0, 1, MAY_BE_ARRAY|MAY_BE_LONG) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, format, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO(0, charlist, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charlist, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_str_split, 0, 1, IS_ARRAY, 0) @@ -1103,18 +1103,18 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_opendir, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) - ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_getdir, 0, 1, Directory, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) - ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null") ZEND_END_ARG_INFO() #define arginfo_dir arginfo_getdir ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_closedir, 0, 0, IS_VOID, 0) - ZEND_ARG_INFO(0, dir_handle) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, dir_handle, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_chdir, 0, 1, _IS_BOOL, 0) @@ -1132,13 +1132,13 @@ ZEND_END_ARG_INFO() #define arginfo_rewinddir arginfo_closedir ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_readdir, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_INFO(0, dir_handle) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, dir_handle, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scandir, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sorting_order, IS_LONG, 0, "0") - ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null") ZEND_END_ARG_INFO() #if defined(HAVE_GLOB) @@ -1218,7 +1218,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rmdir, 0, 1, _IS_BOOL, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_umask, 0, 0, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, mask, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mask, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #define arginfo_fclose arginfo_rewind @@ -1231,7 +1231,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fgets, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_INFO(0, handle) - ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fread, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) @@ -1278,7 +1278,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_INFO(0, handle) ZEND_ARG_TYPE_INFO(0, content, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, max_length, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #define arginfo_fputs arginfo_fwrite @@ -1444,8 +1444,8 @@ ZEND_END_ARG_INFO() #if HAVE_UTIME ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_touch, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, time, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, atime, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, time, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, atime, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #endif @@ -1503,7 +1503,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_fsockopen, 0, 0, 1) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "-1") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, errno, "null") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, errstr, "null") - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 1, "null") ZEND_END_ARG_INFO() #define arginfo_pfsockopen arginfo_fsockopen @@ -1539,7 +1539,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phpinfo, 0, 0, _IS_BOOL, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_phpversion, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extension, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phpcredits, 0, 0, _IS_BOOL, 0) @@ -1601,7 +1601,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mail, 0, 3, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0) - ZEND_ARG_TYPE_MASK(0, additional_headers, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_MASK(0, additional_headers, MAY_BE_ARRAY|MAY_BE_STRING, "[]") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, additional_parameters, IS_STRING, 0, "\"\"") ZEND_END_ARG_INFO() @@ -1887,7 +1887,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stream_context_get_options, 0, 1 ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_get_default, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_context_set_default, 0, 0, 1) @@ -1898,7 +1898,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_filter_prepend, 0, 0, 2) ZEND_ARG_INFO(0, stream) ZEND_ARG_TYPE_INFO(0, filtername, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, read_write, IS_LONG, 0, "0") - ZEND_ARG_INFO(0, params) + ZEND_ARG_TYPE_INFO(0, params, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_stream_filter_append arginfo_stream_filter_prepend @@ -1911,7 +1911,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_socket_client, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, remote_socket, IS_STRING, 0) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, errno, "null") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, errstr, "null") - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "STREAM_CLIENT_CONNECT") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null") ZEND_END_ARG_INFO() @@ -1926,7 +1926,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_socket_accept, 0, 0, 1) ZEND_ARG_INFO(0, server_socket) - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 1, "null") ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, peername, "null") ZEND_END_ARG_INFO() @@ -1974,13 +1974,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stream_copy_to_stream, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_INFO(0, source) ZEND_ARG_INFO(0, dest) - ZEND_ARG_TYPE_INFO(0, maxlength, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlength, IS_LONG, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, position, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_stream_get_contents, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_INFO(0, handle) - ZEND_ARG_TYPE_INFO(0, maxlength, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlength, IS_LONG, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, position, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() @@ -2199,7 +2199,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_version_compare, 0, 2, MAY_BE_LONG|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, version1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, version2, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, operator, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, operator, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #if defined(PHP_WIN32) @@ -2210,7 +2210,7 @@ ZEND_END_ARG_INFO() #if defined(PHP_WIN32) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_sapi_windows_cp_get, 0, 0, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, kind, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, kind, IS_STRING, 0, "\"\"") ZEND_END_ARG_INFO() #endif diff --git a/ext/standard/dir.c b/ext/standard/dir.c index e480c245fe..98bff12fc2 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -61,9 +61,9 @@ static zend_class_entry *dir_class_entry_ptr; #define FETCH_DIRP() \ ZEND_PARSE_PARAMETERS_START(0, 1) \ Z_PARAM_OPTIONAL \ - Z_PARAM_RESOURCE(id) \ + Z_PARAM_RESOURCE_OR_NULL(id) \ ZEND_PARSE_PARAMETERS_END(); \ - if (ZEND_NUM_ARGS() == 0) { \ + if (!id) { \ myself = getThis(); \ if (myself) { \ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \ @@ -201,7 +201,7 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_PATH(dirname, dir_len) Z_PARAM_OPTIONAL - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); @@ -538,7 +538,7 @@ PHP_FUNCTION(scandir) Z_PARAM_PATH(dirn, dirn_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(flags) - Z_PARAM_RESOURCE(zcontext) + Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); if (dirn_len < 1) { diff --git a/ext/standard/dir.stub.php b/ext/standard/dir.stub.php index 39881f759b..86d08c1e1d 100755 --- a/ext/standard/dir.stub.php +++ b/ext/standard/dir.stub.php @@ -5,23 +5,23 @@ class Directory { /** - * @param resource $dir_handle + * @param resource|null $dir_handle * @return void * @alias closedir */ - public function close($dir_handle = UNKNOWN) {} + public function close($dir_handle = null) {} /** - * @param resource $dir_handle + * @param resource|null $dir_handle * @return void * @alias rewinddir */ - public function rewind($dir_handle = UNKNOWN) {} + public function rewind($dir_handle = null) {} /** - * @param resource $dir_handle + * @param resource|null $dir_handle * @return string|false * @alias readdir */ - public function read($dir_handle = UNKNOWN) {} + public function read($dir_handle = null) {} } diff --git a/ext/standard/dir_arginfo.h b/ext/standard/dir_arginfo.h index 68571fe8be..67a22b7249 100644 --- a/ext/standard/dir_arginfo.h +++ b/ext/standard/dir_arginfo.h @@ -1,8 +1,8 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ae14c81d7c4642412440f6236b34b7c7c0143911 */ + * Stub hash: 2670287ef059725cceda0a8f9ac6515cdcedb521 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Directory_close, 0, 0, 0) - ZEND_ARG_INFO(0, dir_handle) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, dir_handle, "null") ZEND_END_ARG_INFO() #define arginfo_class_Directory_rewind arginfo_class_Directory_close diff --git a/ext/standard/file.c b/ext/standard/file.c index 9883973c5d..6f29343d9f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1015,8 +1015,8 @@ PHPAPI PHP_FUNCTION(fgets) { zval *res; zend_long len = 1024; + zend_bool len_is_null = 1; char *buf = NULL; - int argc = ZEND_NUM_ARGS(); size_t line_len = 0; zend_string *str; php_stream *stream; @@ -1024,12 +1024,12 @@ PHPAPI PHP_FUNCTION(fgets) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_RESOURCE(res) Z_PARAM_OPTIONAL - Z_PARAM_LONG(len) + Z_PARAM_LONG_OR_NULL(len, len_is_null) ZEND_PARSE_PARAMETERS_END(); PHP_STREAM_TO_ZVAL(stream, res); - if (argc == 1) { + if (len_is_null) { /* ask streams to give us a buffer of an appropriate size */ buf = php_stream_get_line(stream, NULL, 0, &line_len); if (buf == NULL) { @@ -1038,7 +1038,7 @@ PHPAPI PHP_FUNCTION(fgets) // TODO: avoid reallocation ??? RETVAL_STRINGL(buf, line_len); efree(buf); - } else if (argc > 1) { + } else { if (len <= 0) { zend_argument_value_error(2, "must be greater than 0"); RETURN_THROWS(); @@ -1138,16 +1138,17 @@ PHPAPI PHP_FUNCTION(fwrite) ssize_t ret; size_t num_bytes; zend_long maxlen = 0; + zend_bool maxlen_is_null = 1; php_stream *stream; ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_RESOURCE(res) Z_PARAM_STRING(input, inputlen) Z_PARAM_OPTIONAL - Z_PARAM_LONG(maxlen) + Z_PARAM_LONG_OR_NULL(maxlen, maxlen_is_null) ZEND_PARSE_PARAMETERS_END(); - if (ZEND_NUM_ARGS() == 2) { + if (maxlen_is_null) { num_bytes = inputlen; } else if (maxlen <= 0) { num_bytes = 0; @@ -1354,20 +1355,21 @@ PHP_FUNCTION(readfile) PHP_FUNCTION(umask) { zend_long mask = 0; + zend_bool mask_is_null = 1; int oldumask; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(mask, mask_is_null) + ZEND_PARSE_PARAMETERS_END(); + oldumask = umask(077); if (BG(umask) == -1) { BG(umask) = oldumask; } - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(mask) - ZEND_PARSE_PARAMETERS_END(); - - if (ZEND_NUM_ARGS() == 0) { + if (mask_is_null) { umask(oldumask); } else { umask((int) mask); diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index cb0b406a32..3e431c744d 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -598,7 +598,8 @@ PHP_FUNCTION(touch) char *filename; size_t filename_len; zend_long filetime = 0, fileatime = 0; - int ret, argc = ZEND_NUM_ARGS(); + zend_bool filetime_is_null = 1, fileatime_is_null = 1; + int ret; FILE *file; struct utimbuf newtimebuf; struct utimbuf *newtime = &newtimebuf; @@ -607,28 +608,24 @@ PHP_FUNCTION(touch) ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_PATH(filename, filename_len) Z_PARAM_OPTIONAL - Z_PARAM_LONG(filetime) - Z_PARAM_LONG(fileatime) + Z_PARAM_LONG_OR_NULL(filetime, filetime_is_null) + Z_PARAM_LONG_OR_NULL(fileatime, fileatime_is_null) ZEND_PARSE_PARAMETERS_END(); if (!filename_len) { RETURN_FALSE; } - switch (argc) { - case 1: - newtime = NULL; - break; - case 2: - newtime->modtime = newtime->actime = filetime; - break; - case 3: - newtime->modtime = filetime; - newtime->actime = fileatime; - break; - default: - /* Never reached */ - WRONG_PARAM_COUNT; + if (filetime_is_null && fileatime_is_null) { + newtime = NULL; + } else if (!filetime_is_null && fileatime_is_null) { + newtime->modtime = newtime->actime = filetime; + } else if (filetime_is_null && !fileatime_is_null) { + zend_argument_value_error(2, "cannot be null when argument #3 ($atime) is an integer"); + RETURN_THROWS(); + } else { + newtime->modtime = filetime; + newtime->actime = fileatime; } wrapper = php_stream_locate_url_wrapper(filename, NULL, 0); @@ -641,7 +638,7 @@ PHP_FUNCTION(touch) } } else { php_stream *stream; - if(argc > 1) { + if(!filetime_is_null || !fileatime_is_null) { php_error_docref(NULL, E_WARNING, "Can not call touch() for a non-standard stream"); RETURN_FALSE; } diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index 6023234cd3..a9c3cb0bf5 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -31,7 +31,8 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent) size_t host_len; zend_long port = -1; zval *zerrno = NULL, *zerrstr = NULL; - double timeout = (double)FG(default_socket_timeout); + double timeout; + zend_bool timeout_is_null = 1; #ifndef PHP_WIN32 time_t conv; #else @@ -45,17 +46,21 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent) size_t hostname_len; zend_string *errstr = NULL; - RETVAL_FALSE; - ZEND_PARSE_PARAMETERS_START(1, 5) Z_PARAM_STRING(host, host_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(port) Z_PARAM_ZVAL(zerrno) Z_PARAM_ZVAL(zerrstr) - Z_PARAM_DOUBLE(timeout) + Z_PARAM_DOUBLE_OR_NULL(timeout, timeout_is_null) ZEND_PARSE_PARAMETERS_END(); + RETVAL_FALSE; + + if (timeout_is_null) { + timeout = (double)FG(default_socket_timeout); + } + if (persistent) { spprintf(&hashkey, 0, "pfsockopen__%s:" ZEND_LONG_FMT, host, port); } diff --git a/ext/standard/head.c b/ext/standard/head.c index ceca0cbbef..cbc7e24a45 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -58,12 +58,12 @@ PHP_FUNCTION(header_remove) ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STRING(line, len) + Z_PARAM_STRING_OR_NULL(line, len) ZEND_PARSE_PARAMETERS_END(); ctr.line = line; ctr.line_len = (uint32_t)len; - sapi_header_op(ZEND_NUM_ARGS() == 0 ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr); + sapi_header_op(line == NULL ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr); } /* }}} */ diff --git a/ext/standard/html.c b/ext/standard/html.c index 58c2989c85..dfed889875 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1395,7 +1395,7 @@ PHP_FUNCTION(html_entity_decode) Z_PARAM_STR(str) Z_PARAM_OPTIONAL Z_PARAM_LONG(quote_style) - Z_PARAM_STR(hint_charset) + Z_PARAM_STR_OR_NULL(hint_charset) ZEND_PARSE_PARAMETERS_END(); replaced = php_unescape_html_entities( diff --git a/ext/standard/info.c b/ext/standard/info.c index 99ba4a179f..153cb6cde0 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -1263,7 +1263,7 @@ PHP_FUNCTION(phpversion) ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STRING(ext_name, ext_name_len) + Z_PARAM_STRING_OR_NULL(ext_name, ext_name_len) ZEND_PARSE_PARAMETERS_END(); if (!ext_name) { diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index f56f52930c..78e3896d5b 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -88,7 +88,8 @@ PHP_FUNCTION(stream_socket_client) { zend_string *host; zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL; - double timeout = (double)FG(default_socket_timeout); + double timeout; + zend_bool timeout_is_null = 1; php_timeout_ull conv; struct timeval tv; char *hashkey = NULL; @@ -98,18 +99,22 @@ PHP_FUNCTION(stream_socket_client) zend_string *errstr = NULL; php_stream_context *context = NULL; - RETVAL_FALSE; - ZEND_PARSE_PARAMETERS_START(1, 6) Z_PARAM_STR(host) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(zerrno) Z_PARAM_ZVAL(zerrstr) - Z_PARAM_DOUBLE(timeout) + Z_PARAM_DOUBLE_OR_NULL(timeout, timeout_is_null) Z_PARAM_LONG(flags) Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); + RETVAL_FALSE; + + if (timeout_is_null) { + timeout = (double)FG(default_socket_timeout); + } + context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); if (flags & PHP_STREAM_CLIENT_PERSISTENT) { @@ -238,7 +243,8 @@ PHP_FUNCTION(stream_socket_server) /* {{{ Accept a client connection from a server socket */ PHP_FUNCTION(stream_socket_accept) { - double timeout = (double)FG(default_socket_timeout); + double timeout; + zend_bool timeout_is_null = 1; zval *zpeername = NULL; zend_string *peername = NULL; php_timeout_ull conv; @@ -250,10 +256,14 @@ PHP_FUNCTION(stream_socket_accept) ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_RESOURCE(zstream) Z_PARAM_OPTIONAL - Z_PARAM_DOUBLE(timeout) + Z_PARAM_DOUBLE_OR_NULL(timeout, timeout_is_null) Z_PARAM_ZVAL(zpeername) ZEND_PARSE_PARAMETERS_END(); + if (timeout_is_null) { + timeout = (double)FG(default_socket_timeout); + } + php_stream_from_zval(stream, zstream); /* prepare the timeout value for use */ @@ -406,21 +416,23 @@ PHP_FUNCTION(stream_socket_recvfrom) /* {{{ Reads all remaining bytes (or up to maxlen bytes) from a stream and returns them as a string. */ PHP_FUNCTION(stream_get_contents) { - php_stream *stream; - zval *zsrc; - zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL, - desiredpos = -1L; + php_stream *stream; + zval *zsrc; + zend_long maxlen, desiredpos = -1L; + zend_bool maxlen_is_null = 1; zend_string *contents; ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_RESOURCE(zsrc) Z_PARAM_OPTIONAL - Z_PARAM_LONG(maxlen) + Z_PARAM_LONG_OR_NULL(maxlen, maxlen_is_null) Z_PARAM_LONG(desiredpos) ZEND_PARSE_PARAMETERS_END(); - if (maxlen < 0 && maxlen != PHP_STREAM_COPY_ALL) { - php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to zero, or -1"); + if (maxlen_is_null) { + maxlen = (ssize_t) PHP_STREAM_COPY_ALL; + } else if (maxlen < 0 && maxlen != PHP_STREAM_COPY_ALL) { + php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to 0, or -1"); RETURN_FALSE; } @@ -463,7 +475,8 @@ PHP_FUNCTION(stream_copy_to_stream) { php_stream *src, *dest; zval *zsrc, *zdest; - zend_long maxlen = PHP_STREAM_COPY_ALL, pos = 0; + zend_long maxlen, pos = 0; + zend_bool maxlen_is_null = 1; size_t len; int ret; @@ -471,10 +484,14 @@ PHP_FUNCTION(stream_copy_to_stream) Z_PARAM_RESOURCE(zsrc) Z_PARAM_RESOURCE(zdest) Z_PARAM_OPTIONAL - Z_PARAM_LONG(maxlen) + Z_PARAM_LONG_OR_NULL(maxlen, maxlen_is_null) Z_PARAM_LONG(pos) ZEND_PARSE_PARAMETERS_END(); + if (maxlen_is_null) { + maxlen = PHP_STREAM_COPY_ALL; + } + php_stream_from_zval(src, zsrc); php_stream_from_zval(dest, zdest); @@ -1074,7 +1091,7 @@ PHP_FUNCTION(stream_context_get_default) ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_HT(params) + Z_PARAM_ARRAY_HT_OR_NULL(params) ZEND_PARSE_PARAMETERS_END(); if (FG(default_context) == NULL) { diff --git a/ext/standard/string.c b/ext/standard/string.c index 5631ce4ac0..915b6cff53 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -68,6 +68,7 @@ void register_string_constants(INIT_FUNC_ARGS) REGISTER_LONG_CONSTANT("PATHINFO_BASENAME", PHP_PATHINFO_BASENAME, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PATHINFO_EXTENSION", PHP_PATHINFO_EXTENSION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PATHINFO_FILENAME", PHP_PATHINFO_FILENAME, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PATHINFO_ALL", PHP_PATHINFO_ALL, CONST_CS | CONST_PERSISTENT); /* If last members of struct lconv equal CHAR_MAX, no grouping is done */ REGISTER_LONG_CONSTANT("CHAR_MAX", CHAR_MAX, CONST_CS | CONST_PERSISTENT); @@ -247,16 +248,17 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) / { zend_string *s11, *s22; zend_long start = 0, len = 0; + zend_bool len_is_null = 1; ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(s11) Z_PARAM_STR(s22) Z_PARAM_OPTIONAL Z_PARAM_LONG(start) - Z_PARAM_LONG(len) + Z_PARAM_LONG_OR_NULL(len, len_is_null) ZEND_PARSE_PARAMETERS_END(); - if (ZEND_NUM_ARGS() < 4) { + if (len_is_null) { len = ZSTR_LEN(s11); } @@ -1228,7 +1230,7 @@ PHP_FUNCTION(implode) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR_OR_ARRAY_HT(arg1_str, arg1_array) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_HT(pieces) + Z_PARAM_ARRAY_HT_OR_NULL(pieces) ZEND_PARSE_PARAMETERS_END(); if (pieces == NULL) { @@ -1265,10 +1267,10 @@ PHP_FUNCTION(strtok) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR(str) Z_PARAM_OPTIONAL - Z_PARAM_STR(tok) + Z_PARAM_STR_OR_NULL(tok) ZEND_PARSE_PARAMETERS_END(); - if (ZEND_NUM_ARGS() == 1) { + if (!tok) { tok = str; } else { if (BG(strtok_string)) { @@ -2239,7 +2241,6 @@ PHP_FUNCTION(substr_replace) zval *len = NULL; zend_long l = 0; zend_long f; - int argc = ZEND_NUM_ARGS(); zend_string *result; HashPosition from_idx, repl_idx, len_idx; zval *tmp_str = NULL, *tmp_repl, *tmp_from = NULL, *tmp_len= NULL; @@ -2249,7 +2250,7 @@ PHP_FUNCTION(substr_replace) Z_PARAM_STR_OR_ARRAY_HT(repl_str, repl_ht) Z_PARAM_ZVAL(from) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL(len) + Z_PARAM_ZVAL_OR_NULL(len) ZEND_PARSE_PARAMETERS_END(); if (Z_TYPE_P(from) != IS_ARRAY) { @@ -2259,7 +2260,7 @@ PHP_FUNCTION(substr_replace) } } - if (argc > 3) { + if (len) { if (Z_TYPE_P(len) != IS_ARRAY) { convert_to_long_ex(len); l = Z_LVAL_P(len); @@ -2272,13 +2273,13 @@ PHP_FUNCTION(substr_replace) if (str) { if ( - (argc == 3 && Z_TYPE_P(from) == IS_ARRAY) || - (argc == 4 && Z_TYPE_P(from) != Z_TYPE_P(len)) + (!len && Z_TYPE_P(from) == IS_ARRAY) || + (len && Z_TYPE_P(from) != Z_TYPE_P(len)) ) { php_error_docref(NULL, E_WARNING, "'start' and 'length' should be of same type - numerical or array "); RETURN_STR_COPY(str); } - if (argc == 4 && Z_TYPE_P(from) == IS_ARRAY) { + if (len && Z_TYPE_P(from) == IS_ARRAY) { if (zend_hash_num_elements(Z_ARRVAL_P(from)) != zend_hash_num_elements(Z_ARRVAL_P(len))) { php_error_docref(NULL, E_WARNING, "'start' and 'length' should have the same number of elements"); RETURN_STR_COPY(str); @@ -2398,7 +2399,7 @@ PHP_FUNCTION(substr_replace) } } - if (argc > 3 && Z_TYPE_P(len) == IS_ARRAY) { + if (len && Z_TYPE_P(len) == IS_ARRAY) { while (len_idx < Z_ARRVAL_P(len)->nNumUsed) { tmp_len = &Z_ARRVAL_P(len)->arData[len_idx].val; if (Z_TYPE_P(tmp_len) != IS_UNDEF) { @@ -2412,7 +2413,7 @@ PHP_FUNCTION(substr_replace) } else { l = ZSTR_LEN(orig_str); } - } else if (argc > 3) { + } else if (len) { l = Z_LVAL_P(len); } else { l = ZSTR_LEN(orig_str); @@ -3204,19 +3205,18 @@ PHP_FUNCTION(strtr) HashTable *from_ht = NULL; char *to = NULL; size_t to_len = 0; - int ac = ZEND_NUM_ARGS(); ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(str) Z_PARAM_STR_OR_ARRAY_HT(from_str, from_ht) Z_PARAM_OPTIONAL - Z_PARAM_STRING(to, to_len) + Z_PARAM_STRING_OR_NULL(to, to_len) ZEND_PARSE_PARAMETERS_END(); - if (ac == 2 && from_ht == NULL) { + if (!to && from_ht == NULL) { zend_argument_type_error(2, "must be of type array, string given"); RETURN_THROWS(); - } else if (ac != 2 && from_str == NULL) { + } else if (to && from_str == NULL) { zend_argument_type_error(2, "must be of type string, array given"); RETURN_THROWS(); } @@ -3226,7 +3226,7 @@ PHP_FUNCTION(strtr) RETURN_EMPTY_STRING(); } - if (ac == 2) { + if (!to) { if (zend_hash_num_elements(from_ht) < 1) { RETURN_STR_COPY(str); } else if (zend_hash_num_elements(from_ht) == 1) { @@ -4249,7 +4249,6 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit zend_string *string_key; zend_ulong num_key; zend_long count = 0; - int argc = ZEND_NUM_ARGS(); ZEND_PARSE_PARAMETERS_START(3, 4) Z_PARAM_STR_OR_ARRAY_HT(search_str, search_ht) @@ -4290,7 +4289,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit } else { /* if subject is not an array */ count = php_str_replace_in_subject(search_str, search_ht, replace_str, replace_ht, subject_str, return_value, case_sensitivity); } - if (argc > 3) { + if (zcount) { ZEND_TRY_ASSIGN_REF_LONG(zcount, count); } } @@ -4562,7 +4561,8 @@ PHP_FUNCTION(strip_tags) { zend_string *buf; zend_string *str; - zval *allow=NULL; + zend_string *allow_str = NULL; + HashTable *allow_ht = NULL; const char *allowed_tags=NULL; size_t allowed_tags_len=0; smart_str tags_ss = {0}; @@ -4570,32 +4570,28 @@ PHP_FUNCTION(strip_tags) ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR(str) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL(allow) + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(allow_str, allow_ht) ZEND_PARSE_PARAMETERS_END(); - if (allow) { - if (Z_TYPE_P(allow) == IS_ARRAY) { - zval *tmp; - zend_string *tag; - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(allow), tmp) { - tag = zval_get_string(tmp); - smart_str_appendc(&tags_ss, '<'); - smart_str_append(&tags_ss, tag); - smart_str_appendc(&tags_ss, '>'); - zend_string_release(tag); - } ZEND_HASH_FOREACH_END(); - if (tags_ss.s) { - smart_str_0(&tags_ss); - allowed_tags = ZSTR_VAL(tags_ss.s); - allowed_tags_len = ZSTR_LEN(tags_ss.s); - } - } else { - /* To maintain a certain BC, we allow anything for the second parameter and return original string */ - convert_to_string(allow); - allowed_tags = Z_STRVAL_P(allow); - allowed_tags_len = Z_STRLEN_P(allow); + if (allow_ht) { + zval *tmp; + zend_string *tag; + + ZEND_HASH_FOREACH_VAL(allow_ht, tmp) { + tag = zval_get_string(tmp); + smart_str_appendc(&tags_ss, '<'); + smart_str_append(&tags_ss, tag); + smart_str_appendc(&tags_ss, '>'); + zend_string_release(tag); + } ZEND_HASH_FOREACH_END(); + if (tags_ss.s) { + smart_str_0(&tags_ss); + allowed_tags = ZSTR_VAL(tags_ss.s); + allowed_tags_len = ZSTR_LEN(tags_ss.s); } + } else if (allow_str) { + allowed_tags = ZSTR_VAL(allow_str); + allowed_tags_len = ZSTR_LEN(allow_str); } buf = zend_string_init(ZSTR_VAL(str), ZSTR_LEN(str), 0); @@ -5753,7 +5749,7 @@ PHP_FUNCTION(str_word_count) Z_PARAM_STR(str) Z_PARAM_OPTIONAL Z_PARAM_LONG(type) - Z_PARAM_STRING(char_list, char_list_len) + Z_PARAM_STRING_OR_NULL(char_list, char_list_len) ZEND_PARSE_PARAMETERS_END(); switch(type) { diff --git a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt index 355a49452d..7e3c53b797 100644 --- a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt +++ b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt @@ -42,21 +42,21 @@ Class [ <internal%s> class Directory ] { Method [ <internal:standard> public method close ] { - Parameters [1] { - Parameter #0 [ <optional> $dir_handle = <default> ] + Parameter #0 [ <optional> $dir_handle = null ] } } Method [ <internal:standard> public method rewind ] { - Parameters [1] { - Parameter #0 [ <optional> $dir_handle = <default> ] + Parameter #0 [ <optional> $dir_handle = null ] } } Method [ <internal:standard> public method read ] { - Parameters [1] { - Parameter #0 [ <optional> $dir_handle = <default> ] + Parameter #0 [ <optional> $dir_handle = null ] } } } diff --git a/ext/standard/tests/file/touch.phpt b/ext/standard/tests/file/touch.phpt index 0474b34af2..32e49f3149 100644 --- a/ext/standard/tests/file/touch.phpt +++ b/ext/standard/tests/file/touch.phpt @@ -35,6 +35,12 @@ var_dump(touch("/no/such/file/or/directory")); @unlink($filename); +try { + touch("/no/such/file/or/directory", null, 1599492068); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + echo "Done\n"; ?> --EXPECTF-- @@ -51,4 +57,5 @@ int(100) Warning: touch(): Unable to create file /no/such/file/or/directory because %s in %s on line %d bool(false) +touch(): Argument #2 ($time) cannot be null when argument #3 ($atime) is an integer Done diff --git a/ext/standard/tests/streams/stream_get_contents_negative_length.phpt b/ext/standard/tests/streams/stream_get_contents_negative_length.phpt index 3d52729a2f..a0efebc1f1 100644 --- a/ext/standard/tests/streams/stream_get_contents_negative_length.phpt +++ b/ext/standard/tests/streams/stream_get_contents_negative_length.phpt @@ -12,5 +12,5 @@ var_dump(stream_get_contents($tmp, -2)); --EXPECTF-- string(2) "bc" -Warning: stream_get_contents(): Length must be greater than or equal to zero, or -1 in %s on line %d +Warning: stream_get_contents(): Length must be greater than or equal to 0, or -1 in %s on line %d bool(false) diff --git a/ext/standard/tests/strings/implode1.phpt b/ext/standard/tests/strings/implode1.phpt Binary files differindex bd0e03c6d5..fdc9d329a8 100644 --- a/ext/standard/tests/strings/implode1.phpt +++ b/ext/standard/tests/strings/implode1.phpt diff --git a/ext/standard/tests/strings/join_variation2.phpt b/ext/standard/tests/strings/join_variation2.phpt index b48c35ca94..5fc83dde79 100644 --- a/ext/standard/tests/strings/join_variation2.phpt +++ b/ext/standard/tests/strings/join_variation2.phpt @@ -102,49 +102,49 @@ echo "Done\n"; --- Testing join() by supplying different values for 'pieces' argument --- -- Iteration 1 -- -join(): Argument #2 ($pieces) must be of type array, int given +join(): Argument #2 ($pieces) must be of type ?array, int given -- Iteration 2 -- -join(): Argument #2 ($pieces) must be of type array, int given +join(): Argument #2 ($pieces) must be of type ?array, int given -- Iteration 3 -- -join(): Argument #2 ($pieces) must be of type array, int given +join(): Argument #2 ($pieces) must be of type ?array, int given -- Iteration 4 -- -join(): Argument #2 ($pieces) must be of type array, int given +join(): Argument #2 ($pieces) must be of type ?array, int given -- Iteration 5 -- -join(): Argument #2 ($pieces) must be of type array, float given +join(): Argument #2 ($pieces) must be of type ?array, float given -- Iteration 6 -- -join(): Argument #2 ($pieces) must be of type array, float given +join(): Argument #2 ($pieces) must be of type ?array, float given -- Iteration 7 -- -join(): Argument #2 ($pieces) must be of type array, float given +join(): Argument #2 ($pieces) must be of type ?array, float given -- Iteration 8 -- -join(): Argument #2 ($pieces) must be of type array, float given +join(): Argument #2 ($pieces) must be of type ?array, float given -- Iteration 9 -- -join(): Argument #2 ($pieces) must be of type array, float given +join(): Argument #2 ($pieces) must be of type ?array, float given -- Iteration 10 -- -join(): Argument #2 ($pieces) must be of type array, bool given +join(): Argument #2 ($pieces) must be of type ?array, bool given -- Iteration 11 -- -join(): Argument #2 ($pieces) must be of type array, bool given +join(): Argument #2 ($pieces) must be of type ?array, bool given -- Iteration 12 -- -join(): Argument #2 ($pieces) must be of type array, bool given +join(): Argument #2 ($pieces) must be of type ?array, bool given -- Iteration 13 -- -join(): Argument #2 ($pieces) must be of type array, bool given +join(): Argument #2 ($pieces) must be of type ?array, bool given -- Iteration 14 -- -join(): Argument #2 ($pieces) must be of type array, string given +join(): Argument #2 ($pieces) must be of type ?array, string given -- Iteration 15 -- -join(): Argument #2 ($pieces) must be of type array, string given +join(): Argument #2 ($pieces) must be of type ?array, string given -- Iteration 16 -- -join(): Argument #2 ($pieces) must be of type array, test given +join(): Argument #2 ($pieces) must be of type ?array, test given -- Iteration 17 -- -join(): Argument #2 ($pieces) must be of type array, string given +join(): Argument #2 ($pieces) must be of type ?array, string given -- Iteration 18 -- -join(): Argument #2 ($pieces) must be of type array, string given +join(): Argument #2 ($pieces) must be of type ?array, string given -- Iteration 19 -- -join(): Argument #2 ($pieces) must be of type array, null given +join(): Argument #1 ($pieces) must be of type array, string given -- Iteration 20 -- -join(): Argument #2 ($pieces) must be of type array, null given +join(): Argument #1 ($pieces) must be of type array, string given -- Iteration 21 -- -join(): Argument #2 ($pieces) must be of type array, resource given +join(): Argument #2 ($pieces) must be of type ?array, resource given -- Iteration 22 -- -join(): Argument #2 ($pieces) must be of type array, null given +join(): Argument #1 ($pieces) must be of type array, string given -- Iteration 23 -- -join(): Argument #2 ($pieces) must be of type array, null given +join(): Argument #1 ($pieces) must be of type array, string given Done diff --git a/ext/standard/tests/strings/strip_tags_variation2.phpt b/ext/standard/tests/strings/strip_tags_variation2.phpt index 794933e7c0..640e353ab2 100644 --- a/ext/standard/tests/strings/strip_tags_variation2.phpt +++ b/ext/standard/tests/strings/strip_tags_variation2.phpt @@ -72,7 +72,11 @@ $values = array( $iterator = 1; foreach($values as $value) { echo "-- Iteration $iterator --\n"; - var_dump( strip_tags($string, $value) ); + try { + var_dump(strip_tags($string, $value)); + } catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; + } $iterator++; }; @@ -121,5 +125,5 @@ string(10) "helloworld" -- Iteration 20 -- string(10) "helloworld" -- Iteration 21 -- -string(10) "helloworld" +strip_tags(): Argument #2 ($allowable_tags) must be of type array|string|null, resource given Done diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c index d46fd26ccd..dbdae6ecf7 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -211,7 +211,7 @@ PHP_FUNCTION(version_compare) Z_PARAM_STRING(v1, v1_len) Z_PARAM_STRING(v2, v2_len) Z_PARAM_OPTIONAL - Z_PARAM_STRING(op, op_len) + Z_PARAM_STRING_OR_NULL(op, op_len) ZEND_PARSE_PARAMETERS_END(); compare = php_version_compare(v1, v2); diff --git a/ext/zlib/zlib.stub.php b/ext/zlib/zlib.stub.php index 8f4ba12c79..f3c96ca545 100644 --- a/ext/zlib/zlib.stub.php +++ b/ext/zlib/zlib.stub.php @@ -41,13 +41,13 @@ function gzuncompress(string $data, int $max_decoded_len = 0): string|false {} * @param resource $fp * @alias fwrite */ -function gzwrite($fp, string $str, int $length = UNKNOWN): int|false {} +function gzwrite($fp, string $str, ?int $length = null): int|false {} /** * @param resource $fp * @alias fwrite */ -function gzputs($fp, string $str, int $length = UNKNOWN): int|false {} +function gzputs($fp, string $str, ?int $length = null): int|false {} /** * @param resource $fp diff --git a/ext/zlib/zlib_arginfo.h b/ext/zlib/zlib_arginfo.h index 134fe9729b..86ce095b3b 100644 --- a/ext/zlib/zlib_arginfo.h +++ b/ext/zlib/zlib_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ee70bdd414ad35521ea24384e22ab05e641d81e0 */ + * Stub hash: b31cdbe9a5d719194753bfe303d32319478048bb */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ob_gzhandler, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) @@ -63,7 +63,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gzwrite, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_INFO(0, fp) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null") ZEND_END_ARG_INFO() #define arginfo_gzputs arginfo_gzwrite |