summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-08-05 18:45:07 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-08-07 12:35:30 +0200
commitaf80d8a14e5540a151e2b40f165ebe122467484b (patch)
treec852017699321228cb32ae5764f817ee64be1a2a /ext/standard
parent3bb183036976fc8bfdf039b41efe1e4312894937 (diff)
downloadphp-git-af80d8a14e5540a151e2b40f165ebe122467484b.tar.gz
Add more argument types to stubs
Closes GH-5943
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/assert.c53
-rwxr-xr-xext/standard/basic_functions.c11
-rwxr-xr-xext/standard/basic_functions.stub.php114
-rwxr-xr-xext/standard/basic_functions_arginfo.h38
-rw-r--r--ext/standard/file.c27
-rw-r--r--ext/standard/http.c2
-rw-r--r--ext/standard/math.c46
-rw-r--r--ext/standard/php_math.h2
-rw-r--r--ext/standard/proc_open.c21
-rw-r--r--ext/standard/tests/assert/assert_basic6.phpt40
-rw-r--r--ext/standard/tests/assert/assert_options_error.phpt2
-rw-r--r--ext/standard/tests/math/base_convert_error.phpt2
-rw-r--r--ext/standard/tests/math/base_convert_variation1.phpt18
-rw-r--r--ext/standard/tests/math/decbin_basic.phpt12
-rw-r--r--ext/standard/tests/math/decbin_basiclong_64bit.phpt10
-rw-r--r--ext/standard/tests/math/decbin_variation1.phpt41
-rw-r--r--ext/standard/tests/math/decbin_variation1_64bit.phpt37
-rw-r--r--ext/standard/tests/math/dechex_basic.phpt12
-rw-r--r--ext/standard/tests/math/dechex_basiclong_64bit.phpt10
-rw-r--r--ext/standard/tests/math/dechex_variation1.phpt39
-rw-r--r--ext/standard/tests/math/dechex_variation1_64bit.phpt38
-rw-r--r--ext/standard/tests/math/decoct_basic.phpt12
-rw-r--r--ext/standard/tests/math/decoct_basiclong_64bit.phpt8
-rw-r--r--ext/standard/tests/math/decoct_variation1.phpt40
-rw-r--r--ext/standard/tests/math/decoct_variation1_64bit.phpt38
25 files changed, 391 insertions, 282 deletions
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index 3203a4e041..f476415f5c 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -139,22 +139,29 @@ PHP_MINFO_FUNCTION(assert) /* {{{ */
PHP_FUNCTION(assert)
{
zval *assertion;
- zval *description = NULL;
+ zend_string *description_str = NULL;
+ zend_object *description_obj = NULL;
- if (! ASSERTG(active)) {
+ if (!ASSERTG(active)) {
RETURN_TRUE;
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL(assertion)
Z_PARAM_OPTIONAL
- Z_PARAM_ZVAL(description)
+ Z_PARAM_STR_OR_OBJ_OF_CLASS_OR_NULL(description_str, description_obj, zend_ce_throwable)
ZEND_PARSE_PARAMETERS_END();
if (zend_is_true(assertion)) {
RETURN_TRUE;
}
+ if (description_obj) {
+ GC_ADDREF(description_obj);
+ zend_throw_exception_internal(description_obj);
+ RETURN_THROWS();
+ }
+
if (Z_TYPE(ASSERTG(callback)) == IS_UNDEF && ASSERTG(cb)) {
ZVAL_STRING(&ASSERTG(callback), ASSERTG(cb));
}
@@ -171,15 +178,14 @@ PHP_FUNCTION(assert)
ZVAL_FALSE(&retval);
- /* XXX do we want to check for error here? */
- if (!description) {
- call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 3, args);
+ if (description_str) {
+ ZVAL_STR(&args[3], description_str);
+ call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 4, args);
+ zval_ptr_dtor(&(args[3]));
zval_ptr_dtor(&(args[2]));
zval_ptr_dtor(&(args[0]));
} else {
- ZVAL_STR(&args[3], zval_get_string(description));
- call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 4, args);
- zval_ptr_dtor(&(args[3]));
+ call_user_function(NULL, NULL, &ASSERTG(callback), &retval, 3, args);
zval_ptr_dtor(&(args[2]));
zval_ptr_dtor(&(args[0]));
}
@@ -188,25 +194,9 @@ PHP_FUNCTION(assert)
}
if (ASSERTG(exception)) {
- if (!description) {
- zend_throw_exception(assertion_error_ce, NULL, E_ERROR);
- } else if (Z_TYPE_P(description) == IS_OBJECT &&
- instanceof_function(Z_OBJCE_P(description), zend_ce_throwable)) {
- Z_ADDREF_P(description);
- zend_throw_exception_object(description);
- } else {
- zend_string *str = zval_get_string(description);
- zend_throw_exception(assertion_error_ce, ZSTR_VAL(str), E_ERROR);
- zend_string_release_ex(str, 0);
- }
+ zend_throw_exception(assertion_error_ce, description_str ? ZSTR_VAL(description_str) : NULL, E_ERROR);
} else if (ASSERTG(warning)) {
- if (!description) {
- php_error_docref(NULL, E_WARNING, "Assertion failed");
- } else {
- zend_string *str = zval_get_string(description);
- php_error_docref(NULL, E_WARNING, "%s failed", ZSTR_VAL(str));
- zend_string_release_ex(str, 0);
- }
+ php_error_docref(NULL, E_WARNING, "%s failed", description_str ? ZSTR_VAL(description_str) : "Assertion failed");
}
if (ASSERTG(bail)) {
@@ -289,9 +279,14 @@ PHP_FUNCTION(assert_options)
} else {
RETVAL_NULL();
}
+
if (ac == 2) {
zval_ptr_dtor(&ASSERTG(callback));
- ZVAL_COPY(&ASSERTG(callback), value);
+ if (Z_TYPE_P(value) == IS_NULL) {
+ ZVAL_UNDEF(&ASSERTG(callback));
+ } else {
+ ZVAL_COPY(&ASSERTG(callback), value);
+ }
}
return;
@@ -312,7 +307,7 @@ PHP_FUNCTION(assert_options)
break;
default:
- zend_argument_value_error(1, "must have a valid value");
+ zend_argument_value_error(1, "must be an ASSERT_* constant");
RETURN_THROWS();
}
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 9b756d8694..51a44a3ffb 100755
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2460,23 +2460,20 @@ PHP_FUNCTION(register_tick_function)
/* {{{ Unregisters a tick callback function */
PHP_FUNCTION(unregister_tick_function)
{
- zval *function;
user_tick_function_entry tick_fe;
+ zend_fcall_info fci;
+ zend_fcall_info_cache fci_cache;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(function)
+ Z_PARAM_FUNC(fci, fci_cache)
ZEND_PARSE_PARAMETERS_END();
if (!BG(user_tick_functions)) {
return;
}
- if (Z_TYPE_P(function) != IS_ARRAY && Z_TYPE_P(function) != IS_OBJECT) {
- convert_to_string(function);
- }
-
tick_fe.arguments = (zval *) emalloc(sizeof(zval));
- ZVAL_COPY_VALUE(&tick_fe.arguments[0], function);
+ ZVAL_COPY_VALUE(&tick_fe.arguments[0], &fci.function_name);
tick_fe.arg_count = 1;
zend_llist_del_element(BG(user_tick_functions), &tick_fe, (int (*)(void *, void *)) user_tick_function_compare);
efree(tick_fe.arguments);
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 31161cdf03..c43eb06d98 100755
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -8,13 +8,12 @@ function set_time_limit(int $seconds): bool {}
/* main/SAPI.c */
-// TODO: Make this a proper callable argument?
-function header_register_callback($callback): bool {}
+function header_register_callback(callable $callback): bool {}
/* main/output.c */
-function ob_start(
- $user_function = null, int $chunk_size = 0, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): bool {}
+/** @param callable $user_function */
+function ob_start($user_function = null, int $chunk_size = 0, int $flags = PHP_OUTPUT_HANDLER_STDFLAGS): bool {}
function ob_flush(): bool {}
@@ -58,7 +57,7 @@ function stream_wrapper_restore(string $protocol): bool {}
/* array.c */
-function array_push(array &$stack, ...$args): int {}
+function array_push(array &$stack, mixed ...$args): int {}
function krsort(array &$arg, int $sort_flags = SORT_REGULAR): bool {}
@@ -110,9 +109,9 @@ function min(mixed $arg, mixed ...$args): mixed {}
function max(mixed $arg, mixed ...$args): mixed {}
-function array_walk(array|object &$input, callable $funcname, $userdata = UNKNOWN): bool {}
+function array_walk(array|object &$input, callable $funcname, mixed $userdata = UNKNOWN): bool {}
-function array_walk_recursive(array|object &$input, callable $funcname, $userdata = UNKNOWN): bool {}
+function array_walk_recursive(array|object &$input, callable $funcname, mixed $userdata = UNKNOWN): bool {}
function in_array(mixed $needle, array $haystack, bool $strict = false): bool {}
@@ -142,7 +141,7 @@ function array_shift(array &$stack): mixed {}
function array_unshift(array &$stack, mixed ...$vars): int {}
-function array_splice(array &$arg, int $offset, ?int $length = null, $replacement = []): array {}
+function array_splice(array &$arg, int $offset, ?int $length = null, mixed $replacement = []): array {}
function array_slice(array $arg, int $offset, ?int $length = null, bool $preserve_keys = false): array {}
@@ -154,7 +153,7 @@ function array_replace(array $arr1, array ...$arrays): array {}
function array_replace_recursive(array $arr1, array ...$arrays): array {}
-function array_keys(array $arg, $search_value = UNKNOWN, bool $strict = false): array {}
+function array_keys(array $arg, mixed $search_value = UNKNOWN, bool $strict = false): array {}
function array_key_first(array $arg): int|string|null {}
@@ -209,6 +208,10 @@ function array_udiff_assoc(array $arr1, array $arr2, ...$rest): array {}
function array_udiff_uassoc(array $arr1, array $arr2, ...$rest): array {}
/**
+ * @param array $arr1
+ * @param int $sort_order
+ * @param int $sort_flags
+ * @param array $arr2
* @prefer-ref $arr1
* @prefer-ref $sort_order
* @prefer-ref $sort_flags
@@ -261,6 +264,7 @@ function getenv(string $variable = UNKNOWN, bool $local_only = false): string|ar
function putenv(string $setting): bool {}
#endif
+/** @param int $optind */
function getopt(string $options, array $longopts = [], &$optind = null): array|false {}
function flush(): void {}
@@ -346,7 +350,7 @@ function getprotobynumber(int $protocol): string|false {}
function register_tick_function(callable $function, mixed ...$args): bool {}
-function unregister_tick_function($function): void {}
+function unregister_tick_function(callable $function): void {}
function is_uploaded_file(string $path): bool {}
@@ -400,11 +404,23 @@ function dns_check_record(string $hostname, string $type = "MX"): bool {}
/** @alias dns_check_record */
function checkdnsrr(string $hostname, string $type = "MX"): bool {}
+/**
+ * @param array $authns
+ * @param array $addtl
+ */
function dns_get_record(string $hostname, int $type = DNS_ANY, &$authns = null, &$addtl = null, bool $raw = false): array|false {}
+/**
+ * @param array $mxhosts
+ * @param array $weight
+ */
function dns_get_mx(string $hostname, &$mxhosts, &$weight = null): bool {}
-/** @alias dns_get_mx */
+/**
+ * @param array $mxhosts
+ * @param array $weight
+ * @alias dns_get_mx
+ */
function getmxrr(string $hostname, &$mxhosts, &$weight = null): bool {}
#endif
@@ -485,6 +501,10 @@ function setcookie(string $name, string $value = '', $expires_or_options = 0, st
function http_response_code(int $response_code = 0): int|bool {}
+/**
+ * @param string $file
+ * @param int $line
+ */
function headers_sent(&$file = null, &$line = null): bool {}
function headers_list(): array {}
@@ -505,9 +525,9 @@ function get_html_translation_table(int $table = HTML_SPECIALCHARS, int $quote_s
/* assert.c */
-/** @param mixed $assertion */
-function assert($assertion, $description = null): bool {}
+function assert(mixed $assertion, Throwable|string|null $description = null): bool {}
+/** @param string|callable|null $value */
function assert_options(int $what, $value = UNKNOWN): array|object|int|string|null {}
/* string.c */
@@ -641,7 +661,8 @@ function nl2br(string $str, bool $is_xhtml = true): string {}
function strip_tags(string $str, $allowable_tags = UNKNOWN): string {}
/**
- * @param string|array $locales
+ * @param array|string $locales
+ * @param string $rest
*/
function setlocale(int $category, $locales, ...$rest): string|false {}
@@ -664,7 +685,7 @@ function substr_count(string $haystack, string $needle, int $offset = 0, ?int $l
function str_pad(string $input, int $pad_length, string $pad_string = " ", int $pad_type = STR_PAD_RIGHT): string {}
-function sscanf(string $str, string $format, &...$vars): array|int|null {}
+function sscanf(string $str, string $format, mixed &...$vars): array|int|null {}
function str_rot13(string $str): string {}
@@ -711,6 +732,7 @@ function getcwd(): string|false {}
/** @param resource $dir_handle */
function rewinddir($dir_handle = UNKNOWN): void {}
+/** @param resource $dir_handle */
function readdir($dir_handle = UNKNOWN): string|false {}
/** @param resource $context */
@@ -722,10 +744,16 @@ function glob(string $pattern, int $flags = 0): array|false {}
/* exec.c */
+/**
+ * @param array $output
+ * @param int $result_code
+ */
function exec(string $command, &$output = null, &$result_code = null): string|false {}
+/** @param int $result_code */
function system(string $command, &$result_code = null): string|false {}
+/** @param int $result_code */
function passthru(string $command, &$result_code = null): bool|null {}
function escapeshellcmd(string $command): string {}
@@ -740,7 +768,10 @@ function proc_nice(int $priority): bool {}
/* file.c */
-/** @param resource $handle */
+/**
+ * @param resource $handle
+ * @param int $wouldblock
+ */
function flock($handle, int $operation, &$wouldblock = null): bool {}
function get_meta_tags(string $filename, bool $use_include_path = false): array|false {}
@@ -831,7 +862,7 @@ function tmpfile() {}
function file(string $filename, int $flags = 0, $context = null): array|false {}
/** @param resource|null $context */
-function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, $maxlen = UNKNOWN): string|false {}
+function file_get_contents(string $filename, bool $use_include_path = false, $context = null, int $offset = 0, ?int $maxlen = null): string|false {}
/** @param resource|null $context */
function unlink(string $filename, $context = null): bool {}
@@ -843,7 +874,7 @@ function file_put_contents(string $filename, mixed $content, int $flags = 0, $co
function fputcsv($handle, array $fields, string $delimiter = ",", string $enclosure = "\"", string $escape = "\\"): int|false {}
/** @param resource $handle */
-function fgetcsv($handle, $length = UNKNOWN, string $delimiter = ",", string $enclosure = '"', string $escape = "\\"): array|false {}
+function fgetcsv($handle, ?int $length = null, string $delimiter = ",", string $enclosure = '"', string $escape = "\\"): array|false {}
function realpath(string $path): string|false {}
@@ -941,15 +972,23 @@ function vfprintf($handle, string $format, array $args): int {}
/* fsock.c */
-/** @return resource|false */
+/**
+ * @param int $errno
+ * @param string $errstr
+ * @return resource|false
+ */
function fsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, float $timeout = UNKNOWN) {}
-/** @return resource|false */
+/**
+ * @param int $errno
+ * @param string $errstr
+ * @return resource|false
+ */
function pfsockopen(string $hostname, int $port = -1, &$errno = null, &$errstr = null, float $timeout = UNKNOWN) {}
/* http.c */
-function http_build_query(array|object $data, string $numeric_prefix = "", $arg_separator = UNKNOWN, int $enc_type = PHP_QUERY_RFC1738): string|false {}
+function http_build_query(array|object $data, string $numeric_prefix = "", ?string $arg_separator = null, int $enc_type = PHP_QUERY_RFC1738): string|false {}
/* image.c */
@@ -957,8 +996,10 @@ function image_type_to_mime_type(int $image_type): string {}
function image_type_to_extension(int $image_type, bool $include_dot = true): string|false {}
+/** @param array $image_info */
function getimagesize(string $image_path, &$image_info = null): array|false {}
+/** @param array $image_info */
function getimagesizefromstring(string $image, &$image_info = null): array|false {}
/* info.c */
@@ -1053,7 +1094,7 @@ function intdiv(int $dividend, int $divisor): int {}
function is_infinite(float $number): bool {}
-function pow($base, $exp): int|float|object {}
+function pow(mixed $base, mixed $exp): int|float|object {}
function exp(float $number): float {}
@@ -1075,13 +1116,13 @@ function hexdec(string $hex_string): int|float {}
function octdec(string $octal_string): int|float {}
-function decbin($number): string {}
+function decbin(int $number): string {}
-function decoct($number): string {}
+function decoct(int $number): string {}
-function dechex($number): string {}
+function dechex(int $number): string {}
-function base_convert($number, int $frombase, int $tobase): string {}
+function base_convert(string $number, int $frombase, int $tobase): string {}
function number_format(float $number, int $decimals = 0, ?string $decimal_point = "." , ?string $thousands_separator = ","): string {}
@@ -1103,7 +1144,7 @@ function getrusage(int $who = 0): array|false {}
/* pack.c */
-function pack(string $format, ...$args): string|false {}
+function pack(string $format, mixed ...$args): string|false {}
function unpack(string $format, string $data, int $offset = 0): array|false {}
@@ -1111,8 +1152,10 @@ function unpack(string $format, string $data, int $offset = 0): array|false {}
function password_get_info(string $hash): ?array {}
+/** @param string|int $algo */
function password_hash(string $password, $algo, array $options = []): string {}
+/** @param string|int $algo */
function password_needs_rehash(string $hash, $algo, array $options = []): bool {}
function password_verify(string $password, string $hash): bool {}
@@ -1122,8 +1165,11 @@ function password_algos(): array {}
/* proc_open.c */
#ifdef PHP_CAN_SUPPORT_PROC_OPEN
-/** @return resource|false */
-function proc_open($cmd, array $descriptorspec, &$pipes, ?string $cwd = null, ?array $env = null, ?array $other_options = null) {}
+/**
+ * @param array $pipes
+ * @return resource|false
+ */
+function proc_open(array|string $cmd, array $descriptorspec, &$pipes, ?string $cwd = null, ?array $env = null, ?array $other_options = null) {}
/** @param resource $process */
function proc_close($process): int {}
@@ -1214,12 +1260,16 @@ function stream_filter_append($stream, string $filtername, int $read_write = 0,
function stream_filter_remove($stream_filter): bool {}
/**
+ * @param int $errno
+ * @param string $errstr
* @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) {}
/**
+ * @param int $errno
+ * @param string $errstr
* @param resource|null $context
* @return resource|false
*/
@@ -1228,6 +1278,7 @@ function stream_socket_server(string $local_socket, &$errno = null, &$errstr = n
/**
* @param resource $server_socket
* @param float $timeout
+ * @param string $peername
* @return resource|false
*/
function stream_socket_accept($server_socket, float $timeout = UNKNOWN, &$peername = null) {}
@@ -1235,7 +1286,10 @@ function stream_socket_accept($server_socket, float $timeout = UNKNOWN, &$peerna
/** @param resource $handle */
function stream_socket_get_name($handle, bool $want_peer): string|false {}
-/** @param resource $socket */
+/**
+ * @param resource $socket
+ * @param string|null $address
+ */
function stream_socket_recvfrom($socket, int $length, int $flags = 0, &$address = null): string|false {}
/** @param resource $socket */
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index 9eb97f1df3..d470f1caf3 100755
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -1,12 +1,12 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: ced7e5bc2c202a0678a5616bc1ffd2ef0df66723 */
+ * Stub hash: ec90be5aaa5a4bb776200e2ab6848d19564f66dd */
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)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_header_register_callback, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, callback)
+ ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_start, 0, 0, _IS_BOOL, 0)
@@ -71,7 +71,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_push, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(1, stack, IS_ARRAY, 0)
- ZEND_ARG_VARIADIC_INFO(0, args)
+ ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_krsort, 0, 1, _IS_BOOL, 0)
@@ -141,7 +141,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_walk, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_MASK(1, input, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL)
ZEND_ARG_TYPE_INFO(0, funcname, IS_CALLABLE, 0)
- ZEND_ARG_INFO(0, userdata)
+ ZEND_ARG_TYPE_INFO(0, userdata, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#define arginfo_array_walk_recursive arginfo_array_walk
@@ -203,7 +203,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_splice, 0, 2, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(1, arg, IS_ARRAY, 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_INFO_WITH_DEFAULT_VALUE(0, replacement, "[]")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, replacement, IS_MIXED, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_slice, 0, 2, IS_ARRAY, 0)
@@ -228,7 +228,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_keys, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, arg, IS_ARRAY, 0)
- ZEND_ARG_INFO(0, search_value)
+ ZEND_ARG_TYPE_INFO(0, search_value, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, strict, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
@@ -554,7 +554,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_register_tick_function, 0, 1, _I
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_unregister_tick_function, 0, 1, IS_VOID, 0)
- ZEND_ARG_INFO(0, function)
+ ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_is_uploaded_file, 0, 1, _IS_BOOL, 0)
@@ -797,8 +797,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_get_html_translation_table, 0, 0
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_assert, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, assertion)
- ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, description, "null")
+ ZEND_ARG_TYPE_INFO(0, assertion, IS_MIXED, 0)
+ ZEND_ARG_OBJ_TYPE_MASK(0, description, Throwable, MAY_BE_STRING|MAY_BE_NULL, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_assert_options, 0, 1, MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_LONG|MAY_BE_STRING|MAY_BE_NULL)
@@ -1066,7 +1066,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_sscanf, 0, 2, MAY_BE_ARRAY|MAY_BE_LONG|MAY_BE_NULL)
ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
- ZEND_ARG_VARIADIC_INFO(1, vars)
+ ZEND_ARG_VARIADIC_TYPE_INFO(1, vars, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#define arginfo_str_rot13 arginfo_base64_encode
@@ -1321,7 +1321,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_file_get_contents, 0, 1, MAY_BE_
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0")
- ZEND_ARG_INFO(0, maxlen)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_unlink, 0, 1, _IS_BOOL, 0)
@@ -1346,7 +1346,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_fgetcsv, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_INFO(0, handle)
- ZEND_ARG_INFO(0, length)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, delimiter, IS_STRING, 0, "\",\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enclosure, IS_STRING, 0, "\'\"\'")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, escape, IS_STRING, 0, "\"\\\\\"")
@@ -1511,7 +1511,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_http_build_query, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_MASK(0, data, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, numeric_prefix, IS_STRING, 0, "\"\"")
- ZEND_ARG_INFO(0, arg_separator)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg_separator, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enc_type, IS_LONG, 0, "PHP_QUERY_RFC1738")
ZEND_END_ARG_INFO()
@@ -1672,8 +1672,8 @@ ZEND_END_ARG_INFO()
#define arginfo_is_infinite arginfo_is_finite
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pow, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_OBJECT)
- ZEND_ARG_INFO(0, base)
- ZEND_ARG_INFO(0, exp)
+ ZEND_ARG_TYPE_INFO(0, base, IS_MIXED, 0)
+ ZEND_ARG_TYPE_INFO(0, exp, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#define arginfo_exp arginfo_sin
@@ -1709,7 +1709,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_octdec, 0, 1, MAY_BE_LONG|MAY_BE
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_decbin, 0, 1, IS_STRING, 0)
- ZEND_ARG_INFO(0, number)
+ ZEND_ARG_TYPE_INFO(0, number, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_decoct arginfo_decbin
@@ -1717,7 +1717,7 @@ ZEND_END_ARG_INFO()
#define arginfo_dechex arginfo_decbin
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_base_convert, 0, 3, IS_STRING, 0)
- ZEND_ARG_INFO(0, number)
+ ZEND_ARG_TYPE_INFO(0, number, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, frombase, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, tobase, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -1756,7 +1756,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pack, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
- ZEND_ARG_VARIADIC_INFO(0, args)
+ ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_unpack, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
@@ -1790,7 +1790,7 @@ ZEND_END_ARG_INFO()
#if defined(PHP_CAN_SUPPORT_PROC_OPEN)
ZEND_BEGIN_ARG_INFO_EX(arginfo_proc_open, 0, 0, 3)
- ZEND_ARG_INFO(0, cmd)
+ ZEND_ARG_TYPE_MASK(0, cmd, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_INFO(0, descriptorspec, IS_ARRAY, 0)
ZEND_ARG_INFO(1, pipes)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cwd, IS_STRING, 1, "null")
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 058d78688d..9c08d16329 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -520,7 +520,8 @@ PHP_FUNCTION(file_get_contents)
zend_bool use_include_path = 0;
php_stream *stream;
zend_long offset = 0;
- zend_long maxlen = (ssize_t) PHP_STREAM_COPY_ALL;
+ zend_long maxlen;
+ zend_bool maxlen_is_null = 1;
zval *zcontext = NULL;
php_stream_context *context = NULL;
zend_string *contents;
@@ -532,10 +533,12 @@ PHP_FUNCTION(file_get_contents)
Z_PARAM_BOOL(use_include_path)
Z_PARAM_RESOURCE_OR_NULL(zcontext)
Z_PARAM_LONG(offset)
- Z_PARAM_LONG(maxlen)
+ Z_PARAM_LONG_OR_NULL(maxlen, maxlen_is_null)
ZEND_PARSE_PARAMETERS_END();
- if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
+ if (maxlen_is_null) {
+ maxlen = (ssize_t) PHP_STREAM_COPY_ALL;
+ } else if (maxlen < 0) {
zend_argument_value_error(5, "must be greater than or equal to 0");
RETURN_THROWS();
}
@@ -1914,7 +1917,8 @@ PHP_FUNCTION(fgetcsv)
php_stream *stream;
{
- zval *fd, *len_zv = NULL;
+ zval *fd;
+ zend_bool len_is_null = 1;
char *delimiter_str = NULL;
size_t delimiter_str_len = 0;
char *enclosure_str = NULL;
@@ -1925,7 +1929,7 @@ PHP_FUNCTION(fgetcsv)
ZEND_PARSE_PARAMETERS_START(1, 5)
Z_PARAM_RESOURCE(fd)
Z_PARAM_OPTIONAL
- Z_PARAM_ZVAL(len_zv)
+ Z_PARAM_LONG_OR_NULL(len, len_is_null)
Z_PARAM_STRING(delimiter_str, delimiter_str_len)
Z_PARAM_STRING(enclosure_str, enclosure_str_len)
Z_PARAM_STRING(escape_str, escape_str_len)
@@ -1968,16 +1972,11 @@ PHP_FUNCTION(fgetcsv)
}
}
- if (len_zv != NULL && Z_TYPE_P(len_zv) != IS_NULL) {
- len = zval_get_long(len_zv);
- if (len < 0) {
- zend_argument_value_error(2, "must be a greater than or equal to 0");
- RETURN_THROWS();
- } else if (len == 0) {
- len = -1;
- }
- } else {
+ if (len_is_null || len == 0) {
len = -1;
+ } else if (len < 0) {
+ zend_argument_value_error(2, "must be a greater than or equal to 0");
+ RETURN_THROWS();
}
PHP_STREAM_TO_ZVAL(stream, fd);
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 0536ea0aa4..3819065894 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -241,7 +241,7 @@ PHP_FUNCTION(http_build_query)
Z_PARAM_ARRAY_OR_OBJECT(formdata)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(prefix, prefix_len)
- Z_PARAM_STRING(arg_sep, arg_sep_len)
+ Z_PARAM_STRING_OR_NULL(arg_sep, arg_sep_len)
Z_PARAM_LONG(enc_type)
ZEND_PARSE_PARAMETERS_END();
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 8dbe0f7653..d0c2708256 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -795,18 +795,18 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
* Convert a long to a string containing a base(2-36) representation of
* the number.
*/
-PHPAPI zend_string * _php_math_longtobase(zval *arg, int base)
+PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base)
{
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
char buf[(sizeof(zend_ulong) << 3) + 1];
char *ptr, *end;
zend_ulong value;
- if (Z_TYPE_P(arg) != IS_LONG || base < 2 || base > 36) {
+ if (base < 2 || base > 36) {
return ZSTR_EMPTY_ALLOC();
}
- value = Z_LVAL_P(arg);
+ value = arg;
end = ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
@@ -856,7 +856,7 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base)
return zend_string_init(ptr, end - ptr, 0);
}
- return _php_math_longtobase(arg, base);
+ return _php_math_longtobase(Z_LVAL_P(arg), base);
}
/* }}} */
@@ -902,68 +902,56 @@ PHP_FUNCTION(octdec)
/* {{{ Returns a string containing a binary representation of the number */
PHP_FUNCTION(decbin)
{
- zval *arg;
- zend_string *result;
+ zend_long arg;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(arg)
+ Z_PARAM_LONG(arg)
ZEND_PARSE_PARAMETERS_END();
- convert_to_long_ex(arg);
- result = _php_math_longtobase(arg, 2);
- RETURN_STR(result);
+ RETURN_STR(_php_math_longtobase(arg, 2));
}
/* }}} */
/* {{{ Returns a string containing an octal representation of the given number */
PHP_FUNCTION(decoct)
{
- zval *arg;
- zend_string *result;
+ zend_long arg;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(arg)
+ Z_PARAM_LONG(arg)
ZEND_PARSE_PARAMETERS_END();
- convert_to_long_ex(arg);
- result = _php_math_longtobase(arg, 8);
- RETURN_STR(result);
+ RETURN_STR(_php_math_longtobase(arg, 8));
}
/* }}} */
/* {{{ Returns a string containing a hexadecimal representation of the given number */
PHP_FUNCTION(dechex)
{
- zval *arg;
- zend_string *result;
+ zend_long arg;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_ZVAL(arg)
+ Z_PARAM_LONG(arg)
ZEND_PARSE_PARAMETERS_END();
- convert_to_long_ex(arg);
- result = _php_math_longtobase(arg, 16);
- RETURN_STR(result);
+ RETURN_STR(_php_math_longtobase(arg, 16));
}
/* }}} */
/* {{{ Converts a number in a string from any base <= 36 to any base <= 36 */
PHP_FUNCTION(base_convert)
{
- zval *number, temp;
+ zval temp;
+ zend_string *number;
zend_long frombase, tobase;
zend_string *result;
ZEND_PARSE_PARAMETERS_START(3, 3)
- Z_PARAM_ZVAL(number)
+ Z_PARAM_STR(number)
Z_PARAM_LONG(frombase)
Z_PARAM_LONG(tobase)
ZEND_PARSE_PARAMETERS_END();
- if (!try_convert_to_string(number)) {
- RETURN_THROWS();
- }
-
if (frombase < 2 || frombase > 36) {
zend_argument_value_error(2, "must be between 2 and 36 (inclusive)");
RETURN_THROWS();
@@ -973,7 +961,7 @@ PHP_FUNCTION(base_convert)
RETURN_THROWS();
}
- _php_math_basetozval(Z_STR_P(number), (int)frombase, &temp);
+ _php_math_basetozval(number, (int)frombase, &temp);
result = _php_math_zvaltobase(&temp, (int)tobase);
RETVAL_STR(result);
}
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index c3ce7cc728..d592b131e9 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -21,7 +21,7 @@
PHPAPI double _php_math_round(double value, int places, int mode);
PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep);
PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
-PHPAPI zend_string * _php_math_longtobase(zval *arg, int base);
+PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base);
PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);
PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 501d2c3f35..5e7a782471 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -605,7 +605,7 @@ static int convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
#endif
/* Convert command parameter array passed as first argument to `proc_open` into command string */
-static char* get_command_from_array(zval *array, char ***argv, int num_elems)
+static char* get_command_from_array(HashTable *array, char ***argv, int num_elems)
{
zval *arg_zv;
char *command = NULL;
@@ -613,7 +613,7 @@ static char* get_command_from_array(zval *array, char ***argv, int num_elems)
*argv = safe_emalloc(sizeof(char *), num_elems + 1, 0);
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), arg_zv) {
+ ZEND_HASH_FOREACH_VAL(array, arg_zv) {
zend_string *arg_str = get_valid_arg_string(arg_zv, i + 1);
if (!arg_str) {
/* Terminate with NULL so exit_fail code knows how many entries to free */
@@ -992,7 +992,9 @@ static void efree_argv(char **argv)
/* {{{ Execute a command, with specified files used for input/output */
PHP_FUNCTION(proc_open)
{
- zval *command_zv, *descriptorspec, *pipes; /* Mandatory arguments */
+ zend_string *command_str;
+ HashTable *command_ht;
+ zval *descriptorspec, *pipes; /* Mandatory arguments */
char *cwd = NULL; /* Optional argument */
size_t cwd_len = 0; /* Optional argument */
zval *environment = NULL, *other_options = NULL; /* Optional arguments */
@@ -1028,7 +1030,7 @@ PHP_FUNCTION(proc_open)
php_process_handle *proc;
ZEND_PARSE_PARAMETERS_START(3, 6)
- Z_PARAM_ZVAL(command_zv)
+ Z_PARAM_STR_OR_ARRAY_HT(command_str, command_ht)
Z_PARAM_ARRAY(descriptorspec)
Z_PARAM_ZVAL(pipes)
Z_PARAM_OPTIONAL
@@ -1039,8 +1041,8 @@ PHP_FUNCTION(proc_open)
memset(&env, 0, sizeof(env));
- if (Z_TYPE_P(command_zv) == IS_ARRAY) {
- uint32_t num_elems = zend_hash_num_elements(Z_ARRVAL_P(command_zv));
+ if (command_ht) {
+ uint32_t num_elems = zend_hash_num_elements(command_ht);
if (num_elems == 0) {
zend_argument_value_error(1, "must have at least one element");
RETURN_THROWS();
@@ -1049,19 +1051,18 @@ PHP_FUNCTION(proc_open)
#ifdef PHP_WIN32
/* Automatically bypass shell if command is given as an array */
bypass_shell = 1;
- command = create_win_command_from_args(Z_ARRVAL_P(command_zv));
+ command = create_win_command_from_args(command_ht);
if (!command) {
RETURN_FALSE;
}
#else
- command = get_command_from_array(command_zv, &argv, num_elems);
+ command = get_command_from_array(command_ht, &argv, num_elems);
if (command == NULL) {
goto exit_fail;
}
#endif
} else {
- convert_to_string(command_zv);
- command = estrdup(Z_STRVAL_P(command_zv));
+ command = estrdup(ZSTR_VAL(command_str));
}
#ifdef PHP_WIN32
diff --git a/ext/standard/tests/assert/assert_basic6.phpt b/ext/standard/tests/assert/assert_basic6.phpt
new file mode 100644
index 0000000000..fdeffb057c
--- /dev/null
+++ b/ext/standard/tests/assert/assert_basic6.phpt
@@ -0,0 +1,40 @@
+--TEST--
+assert() - Remove the assert callback
+--INI--
+assert.active=1
+--FILE--
+<?php
+
+function f1()
+{
+ echo "foo\n";
+}
+
+assert_options(ASSERT_CALLBACK, "f1");
+var_dump(assert_options(ASSERT_CALLBACK));
+
+try {
+ assert(false);
+} catch (AssertionError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+echo "\n";
+
+assert_options(ASSERT_CALLBACK, null);
+var_dump(assert_options(ASSERT_CALLBACK));
+
+try {
+ assert(false);
+} catch (AssertionError $exception) {
+ echo $exception->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+string(2) "f1"
+foo
+assert(false)
+
+NULL
+assert(false)
diff --git a/ext/standard/tests/assert/assert_options_error.phpt b/ext/standard/tests/assert/assert_options_error.phpt
index ba92867737..23ca2e9e03 100644
--- a/ext/standard/tests/assert/assert_options_error.phpt
+++ b/ext/standard/tests/assert/assert_options_error.phpt
@@ -10,4 +10,4 @@ try {
}
?>
--EXPECT--
-assert_options(): Argument #1 ($what) must have a valid value
+assert_options(): Argument #1 ($what) must be an ASSERT_* constant
diff --git a/ext/standard/tests/math/base_convert_error.phpt b/ext/standard/tests/math/base_convert_error.phpt
index e6e9d5b49e..b2cf396ae3 100644
--- a/ext/standard/tests/math/base_convert_error.phpt
+++ b/ext/standard/tests/math/base_convert_error.phpt
@@ -31,4 +31,4 @@ try {
*** Testing base_convert() : error conditions ***
base_convert(): Argument #2 ($frombase) must be between 2 and 36 (inclusive)
base_convert(): Argument #3 ($tobase) must be between 2 and 36 (inclusive)
-Object of class classA could not be converted to string
+base_convert(): Argument #1 ($number) must be of type string, classA given
diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt
index 0f08b2d8ab..a1365b3e74 100644
--- a/ext/standard/tests/math/base_convert_variation1.phpt
+++ b/ext/standard/tests/math/base_convert_variation1.phpt
@@ -66,9 +66,13 @@ $inputs = array(
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
- var_dump(base_convert($input, 10, 8));
+ try {
+ var_dump(base_convert($input, 10, 8));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
$iterator++;
-};
+}
fclose($fp);
?>
--EXPECTF--
@@ -141,11 +145,7 @@ string(1) "0"
string(1) "0"
-- Iteration 19 --
-
-Warning: Array to string conversion in %s on line %d
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "0"
+base_convert(): Argument #1 ($number) must be of type string, array given
-- Iteration 20 --
@@ -169,6 +169,4 @@ string(1) "0"
string(1) "0"
-- Iteration 25 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "5"
+base_convert(): Argument #1 ($number) must be of type string, resource given
diff --git a/ext/standard/tests/math/decbin_basic.phpt b/ext/standard/tests/math/decbin_basic.phpt
index da681dfbe8..1366997dcf 100644
--- a/ext/standard/tests/math/decbin_basic.phpt
+++ b/ext/standard/tests/math/decbin_basic.phpt
@@ -17,10 +17,14 @@ $values = array(10,
null,
);
-for ($i = 0; $i < count($values); $i++) {
- $res = decbin($values[$i]);
- var_dump($res);
+foreach ($values as $value) {
+ try {
+ var_dump(decbin($value));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
+
?>
--EXPECT--
string(4) "1010"
@@ -32,7 +36,7 @@ string(4) "1010"
string(12) "111101101110"
string(12) "111101101110"
string(6) "100111"
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
string(1) "1"
string(1) "0"
string(1) "0"
diff --git a/ext/standard/tests/math/decbin_basiclong_64bit.phpt b/ext/standard/tests/math/decbin_basiclong_64bit.phpt
index d48d729bc9..6e4dfa826b 100644
--- a/ext/standard/tests/math/decbin_basiclong_64bit.phpt
+++ b/ext/standard/tests/math/decbin_basiclong_64bit.phpt
@@ -20,8 +20,12 @@ $longVals = array(
foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- var_dump(decbin($longVal));
+ echo "--- testing: $longVal ---\n";
+ try {
+ var_dump(decbin($longVal));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
?>
@@ -51,7 +55,7 @@ string(32) "11111111111111111111111111111101"
--- testing: 9223372036854775806 ---
string(63) "111111111111111111111111111111111111111111111111111111111111110"
--- testing: 9.2233720368548E+18 ---
-string(64) "1000000000000000000000000000000000000000000000000000000000000000"
+decbin(): Argument #1 ($number) must be of type int, float given
--- testing: -9223372036854775807 ---
string(64) "1000000000000000000000000000000000000000000000000000000000000001"
--- testing: -9.2233720368548E+18 ---
diff --git a/ext/standard/tests/math/decbin_variation1.phpt b/ext/standard/tests/math/decbin_variation1.phpt
index 76a9849353..53f4bcaab4 100644
--- a/ext/standard/tests/math/decbin_variation1.phpt
+++ b/ext/standard/tests/math/decbin_variation1.phpt
@@ -77,15 +77,20 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of decbin()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(decbin($input));
- $iterator++;
-};
+
+ try {
+ var_dump(decbin($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
fclose($fp);
+
?>
---EXPECTF--
+--EXPECT--
*** Testing decbin() : usage variations ***
-- Iteration 1 --
@@ -101,10 +106,10 @@ string(14) "11000000111001"
string(32) "11111111111111111111011011010111"
-- Iteration 5 --
-string(32) "11111111111111111111111111111111"
+decbin(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(4) "1010"
@@ -113,7 +118,7 @@ string(4) "1010"
string(32) "11111111111111111111111111110110"
-- Iteration 9 --
-string(32) "10111110100110010001101000001000"
+decbin(): Argument #1 ($number) must be of type int, float given
-- Iteration 10 --
string(1) "0"
@@ -140,27 +145,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+decbin(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -169,4 +172,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%d"
+decbin(): Argument #1 ($number) must be of type int, resource given
diff --git a/ext/standard/tests/math/decbin_variation1_64bit.phpt b/ext/standard/tests/math/decbin_variation1_64bit.phpt
index cfaa600502..ed278bfed0 100644
--- a/ext/standard/tests/math/decbin_variation1_64bit.phpt
+++ b/ext/standard/tests/math/decbin_variation1_64bit.phpt
@@ -77,15 +77,18 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of decbin()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(decbin($input));
- $iterator++;
-};
+ try {
+ var_dump(decbin($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
fclose($fp);
?>
---EXPECTF--
+--EXPECT--
*** Testing decbin() : usage variations ***
-- Iteration 1 --
@@ -101,10 +104,10 @@ string(14) "11000000111001"
string(64) "1111111111111111111111111111111111111111111111111111011011010111"
-- Iteration 5 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(4) "1010"
@@ -140,27 +143,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+decbin(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+decbin(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -169,4 +170,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%d"
+decbin(): Argument #1 ($number) must be of type int, resource given
diff --git a/ext/standard/tests/math/dechex_basic.phpt b/ext/standard/tests/math/dechex_basic.phpt
index 690e2a9842..729685c206 100644
--- a/ext/standard/tests/math/dechex_basic.phpt
+++ b/ext/standard/tests/math/dechex_basic.phpt
@@ -17,10 +17,14 @@ $values = array(10,
null,
);
-for ($i = 0; $i < count($values); $i++) {
- $res = dechex($values[$i]);
- var_dump($res);
+foreach ($values as $value) {
+ try {
+ var_dump(dechex($value));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
+
?>
--EXPECT--
string(1) "a"
@@ -32,7 +36,7 @@ string(1) "a"
string(3) "f6e"
string(3) "f6e"
string(2) "27"
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
string(1) "1"
string(1) "0"
string(1) "0"
diff --git a/ext/standard/tests/math/dechex_basiclong_64bit.phpt b/ext/standard/tests/math/dechex_basiclong_64bit.phpt
index 812bafbfb7..c7727c5ce8 100644
--- a/ext/standard/tests/math/dechex_basiclong_64bit.phpt
+++ b/ext/standard/tests/math/dechex_basiclong_64bit.phpt
@@ -20,8 +20,12 @@ $longVals = array(
foreach ($longVals as $longVal) {
- echo "--- testing: $longVal ---\n";
- var_dump(dechex($longVal));
+ echo "--- testing: $longVal ---\n";
+ try {
+ var_dump(dechex($longVal));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
?>
@@ -51,7 +55,7 @@ string(8) "fffffffd"
--- testing: 9223372036854775806 ---
string(16) "7ffffffffffffffe"
--- testing: 9.2233720368548E+18 ---
-string(16) "8000000000000000"
+dechex(): Argument #1 ($number) must be of type int, float given
--- testing: -9223372036854775807 ---
string(16) "8000000000000001"
--- testing: -9.2233720368548E+18 ---
diff --git a/ext/standard/tests/math/dechex_variation1.phpt b/ext/standard/tests/math/dechex_variation1.phpt
index bd4ed35e3e..5dbe004a07 100644
--- a/ext/standard/tests/math/dechex_variation1.phpt
+++ b/ext/standard/tests/math/dechex_variation1.phpt
@@ -77,15 +77,20 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of dechex()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(dechex($input));
+ try {
+ var_dump(dechex($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
$iterator++;
-};
+}
fclose($fp);
+
?>
---EXPECTF--
+--EXPECT--
*** Testing dechex() : usage variations ***
-- Iteration 1 --
@@ -101,10 +106,10 @@ string(4) "3039"
string(8) "fffff6d7"
-- Iteration 5 --
-string(8) "ffffffff"
+dechex(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(1) "a"
@@ -113,7 +118,7 @@ string(1) "a"
string(8) "fffffff6"
-- Iteration 9 --
-string(8) "be991a08"
+dechex(): Argument #1 ($number) must be of type int, float given
-- Iteration 10 --
string(1) "0"
@@ -140,27 +145,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+dechex(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -169,4 +172,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%s"
+dechex(): Argument #1 ($number) must be of type int, resource given
diff --git a/ext/standard/tests/math/dechex_variation1_64bit.phpt b/ext/standard/tests/math/dechex_variation1_64bit.phpt
index ac815ea1dd..981ccba493 100644
--- a/ext/standard/tests/math/dechex_variation1_64bit.phpt
+++ b/ext/standard/tests/math/dechex_variation1_64bit.phpt
@@ -77,15 +77,19 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of dechex()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(dechex($input));
- $iterator++;
-};
+ try {
+ var_dump(dechex($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
fclose($fp);
+
?>
---EXPECTF--
+--EXPECT--
*** Testing dechex() : usage variations ***
-- Iteration 1 --
@@ -101,10 +105,10 @@ string(4) "3039"
string(16) "fffffffffffff6d7"
-- Iteration 5 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(1) "a"
@@ -140,27 +144,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+dechex(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+dechex(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -169,4 +171,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%s"
+dechex(): Argument #1 ($number) must be of type int, resource given
diff --git a/ext/standard/tests/math/decoct_basic.phpt b/ext/standard/tests/math/decoct_basic.phpt
index 46418df67d..4afdeb466e 100644
--- a/ext/standard/tests/math/decoct_basic.phpt
+++ b/ext/standard/tests/math/decoct_basic.phpt
@@ -17,10 +17,14 @@ $values = array(10,
null,
);
-for ($i = 0; $i < count($values); $i++) {
- $res = decoct($values[$i]);
- var_dump($res);
+foreach ($values as $value) {
+ try {
+ var_dump(decoct($value));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
+
?>
--EXPECT--
string(2) "12"
@@ -32,7 +36,7 @@ string(2) "12"
string(4) "7556"
string(4) "7556"
string(2) "47"
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
string(1) "1"
string(1) "0"
string(1) "0"
diff --git a/ext/standard/tests/math/decoct_basiclong_64bit.phpt b/ext/standard/tests/math/decoct_basiclong_64bit.phpt
index 8b61aa8cbf..0ebc7203f2 100644
--- a/ext/standard/tests/math/decoct_basiclong_64bit.phpt
+++ b/ext/standard/tests/math/decoct_basiclong_64bit.phpt
@@ -21,7 +21,11 @@ $longVals = array(
foreach ($longVals as $longVal) {
echo "--- testing: $longVal ---\n";
- var_dump(decoct($longVal));
+ try {
+ var_dump(decoct($longVal));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
}
?>
@@ -51,7 +55,7 @@ string(11) "37777777775"
--- testing: 9223372036854775806 ---
string(21) "777777777777777777776"
--- testing: 9.2233720368548E+18 ---
-string(22) "1000000000000000000000"
+decoct(): Argument #1 ($number) must be of type int, float given
--- testing: -9223372036854775807 ---
string(22) "1000000000000000000001"
--- testing: -9.2233720368548E+18 ---
diff --git a/ext/standard/tests/math/decoct_variation1.phpt b/ext/standard/tests/math/decoct_variation1.phpt
index 94d385de01..7912566175 100644
--- a/ext/standard/tests/math/decoct_variation1.phpt
+++ b/ext/standard/tests/math/decoct_variation1.phpt
@@ -78,15 +78,19 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of decoct()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach ($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(decoct($input));
- $iterator++;
-};
+ try {
+ var_dump(decoct($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
fclose($fp);
+
?>
---EXPECTF--
+--EXPECT--
*** Testing decoct() : usage variations ***
-- Iteration 1 --
@@ -102,10 +106,10 @@ string(5) "30071"
string(11) "37777773327"
-- Iteration 5 --
-string(11) "37777777777"
+decoct(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(2) "12"
@@ -114,7 +118,7 @@ string(2) "12"
string(11) "37777777766"
-- Iteration 9 --
-string(11) "27646215010"
+decoct(): Argument #1 ($number) must be of type int, float given
-- Iteration 10 --
string(1) "0"
@@ -141,27 +145,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+decoct(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -170,4 +172,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%d"
+decoct(): Argument #1 ($number) must be of type int, resource given
diff --git a/ext/standard/tests/math/decoct_variation1_64bit.phpt b/ext/standard/tests/math/decoct_variation1_64bit.phpt
index 7c1a8f2145..35a9c89288 100644
--- a/ext/standard/tests/math/decoct_variation1_64bit.phpt
+++ b/ext/standard/tests/math/decoct_variation1_64bit.phpt
@@ -78,15 +78,19 @@ $inputs = array(
);
// loop through each element of $inputs to check the behaviour of decoct()
-$iterator = 1;
-foreach($inputs as $input) {
+foreach($inputs as $i => $input) {
+ $iterator = $i + 1;
echo "\n-- Iteration $iterator --\n";
- var_dump(decoct($input));
- $iterator++;
-};
+ try {
+ var_dump(decoct($input));
+ } catch (TypeError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
+}
fclose($fp);
+
?>
---EXPECTF--
+--EXPECT--
*** Testing decoct() : usage variations ***
-- Iteration 1 --
@@ -102,10 +106,10 @@ string(5) "30071"
string(22) "1777777777777777773327"
-- Iteration 5 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, float given
-- Iteration 6 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, float given
-- Iteration 7 --
string(2) "12"
@@ -141,27 +145,25 @@ string(1) "1"
string(1) "0"
-- Iteration 18 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 19 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 20 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, array given
-- Iteration 21 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 22 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 23 --
-string(1) "0"
+decoct(): Argument #1 ($number) must be of type int, string given
-- Iteration 24 --
-
-Notice: Object of class classA could not be converted to int in %s on line %d
-string(1) "1"
+decoct(): Argument #1 ($number) must be of type int, classA given
-- Iteration 25 --
string(1) "0"
@@ -170,4 +172,4 @@ string(1) "0"
string(1) "0"
-- Iteration 27 --
-string(%d) "%d"
+decoct(): Argument #1 ($number) must be of type int, resource given