From 441b326f951126e8abe53ec8d4d6d983eb2f0d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:14:20 +0100 Subject: [PATCH 01/21] Promote warning to exception in log() function --- ext/opcache/Optimizer/zend_func_info.c | 2 +- ext/standard/basic_functions.stub.php | 2 +- ext/standard/basic_functions_arginfo.h | 2 +- ext/standard/math.c | 6 +++--- ext/standard/tests/math/log_error.phpt | 10 +++++++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 7bec6593babde..40f4b53055495 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -291,7 +291,7 @@ static const func_info_t func_infos[] = { F0("log1p", MAY_BE_DOUBLE), F1("pow", MAY_BE_NULL | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_OBJECT), F0("exp", MAY_BE_DOUBLE), - F0("log", MAY_BE_FALSE | MAY_BE_DOUBLE), + F0("log", MAY_BE_DOUBLE), F0("log10", MAY_BE_DOUBLE), F0("sqrt", MAY_BE_DOUBLE), F0("hypot", MAY_BE_DOUBLE), diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index e4fdec71d4bbc..89ba826eb72d5 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -911,7 +911,7 @@ function pow($base, $exp) {} function exp(float $number): float {} -function log(float $number, float $base = M_E): float|false {} +function log(float $number, float $base = M_E): float {} function log10(float $number): float {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 37edc1db21225..e5c4280bbd98f 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1386,7 +1386,7 @@ ZEND_END_ARG_INFO() #define arginfo_exp arginfo_ceil -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_log, 0, 1, MAY_BE_DOUBLE|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_log, 0, 1, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, number, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, base, IS_DOUBLE, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/math.c b/ext/standard/math.c index 18498a21d26da..76d936ec11fc5 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -679,7 +679,7 @@ PHP_FUNCTION(log1p) } /* }}} */ -/* {{{ proto float|false log(float number, [float base]) +/* {{{ proto float log(float number, [float base]) Returns the natural logarithm of the number, or the base log if base is specified */ PHP_FUNCTION(log) { @@ -710,8 +710,8 @@ PHP_FUNCTION(log) } if (base <= 0.0) { - php_error_docref(NULL, E_WARNING, "base must be greater than 0"); - RETURN_FALSE; + zend_value_error("Base must be greater than 0"); + return; } RETURN_DOUBLE(log(num) / log(base)); diff --git a/ext/standard/tests/math/log_error.phpt b/ext/standard/tests/math/log_error.phpt index 7c305a4cba86c..b49ccacf6d700 100644 --- a/ext/standard/tests/math/log_error.phpt +++ b/ext/standard/tests/math/log_error.phpt @@ -4,7 +4,11 @@ Test log() - wrong params test log() precision=14 --FILE-- getMessage() . "\n"; +} ?> ---EXPECTF-- -Warning: log(): base must be greater than 0 in %s on line %d +--EXPECT-- +Base must be greater than 0 From ee3b345beab1ced79278d9618c24cf4920de10a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:17:27 +0100 Subject: [PATCH 02/21] Promote warning to exception in ini_get_all() function --- ext/opcache/Optimizer/zend_func_info.c | 2 +- ext/standard/basic_functions.c | 7 ++-- ext/standard/basic_functions.stub.php | 4 +-- ext/standard/basic_functions_arginfo.h | 2 +- .../tests/general_functions/ini_get_all.phpt | 33 +++++++++++-------- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 40f4b53055495..d0649b3028b3e 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -363,7 +363,7 @@ static const func_info_t func_infos[] = { F1("highlight_string", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING), F1("php_strip_whitespace", MAY_BE_STRING), FN("ini_get", MAY_BE_FALSE | MAY_BE_STRING), - F1("ini_get_all", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY), + F1("ini_get_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY), FN("ini_set", MAY_BE_FALSE | MAY_BE_STRING), F1("ini_alter", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING), F0("ini_restore", MAY_BE_NULL), diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 85cb04d3f0400..db6659e10ed95 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3556,7 +3556,7 @@ PHP_FUNCTION(ini_get) } /* }}} */ -/* {{{ proto array|false ini_get_all([string extension[, bool details = true]]) +/* {{{ proto array ini_get_all([string extension[, bool details = true]]) Get all configuration options */ PHP_FUNCTION(ini_get_all) { @@ -3567,7 +3567,6 @@ PHP_FUNCTION(ini_get_all) zend_string *key; zend_ini_entry *ini_entry; - ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL Z_PARAM_STRING_OR_NULL(extname, extname_len) @@ -3578,8 +3577,8 @@ PHP_FUNCTION(ini_get_all) if (extname) { if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) { - php_error_docref(NULL, E_WARNING, "Unable to find extension '%s'", extname); - RETURN_FALSE; + zend_value_error("Unable to find extension '%s'", extname); + return; } module_number = module->module_number; } diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 89ba826eb72d5..dd93adebb5efa 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -315,7 +315,7 @@ function highlight_string(string $string, bool $return = false): string|bool|nul function ini_get(string $varname): string|false {} -function ini_get_all(?string $extension = null, bool $details = true): array|false {} +function ini_get_all(?string $extension = null, bool $details = true): array {} function ini_set(string $varname, string $value): string|false {} @@ -361,7 +361,7 @@ function is_uploaded_file(string $path): bool {} function move_uploaded_file(string $path, string $new_path): bool {} -function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {} +function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array {} function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index e5c4280bbd98f..1821cf322812e 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -480,7 +480,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get, 0, 1, MAY_BE_STRING|MAY ZEND_ARG_TYPE_INFO(0, varname, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ini_get_all, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ini_get_all, 0, 0, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, extension, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, details, _IS_BOOL, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/general_functions/ini_get_all.phpt b/ext/standard/tests/general_functions/ini_get_all.phpt index ca450f1bc43ba..ea7226fa0b655 100644 --- a/ext/standard/tests/general_functions/ini_get_all.phpt +++ b/ext/standard/tests/general_functions/ini_get_all.phpt @@ -10,25 +10,32 @@ pcre.recursion_limit=100000 getMessage() . "\n"; +} +try { + var_dump(ini_get_all("nosuchextension")); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} var_dump(ini_get_all("reflection")); var_dump(ini_get_all("pcre")); var_dump(ini_get_all("pcre", false)); var_dump(ini_get_all("reflection", false)); - -var_dump(ini_get_all("", "")); +try { + ini_get_all("", ""); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(5) "array" - -Warning: ini_get_all(): Unable to find extension '' in %s on line %d -bool(false) - -Warning: ini_get_all(): Unable to find extension 'nosuchextension' in %s on line %d -bool(false) +Unable to find extension '' +Unable to find extension 'nosuchextension' array(0) { } array(3) { @@ -70,7 +77,5 @@ array(3) { } array(0) { } - -Warning: ini_get_all(): Unable to find extension '' in %sini_get_all.php on line %d -bool(false) +Unable to find extension '' Done From e5a8baed4c33af25641f97f014977ed937af7cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:18:59 +0100 Subject: [PATCH 03/21] Promote warning to exception in parse_ini_file() function --- ext/standard/basic_functions.c | 4 ++-- ext/standard/basic_functions.stub.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index db6659e10ed95..52bfc537c9e43 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4214,8 +4214,8 @@ PHP_FUNCTION(parse_ini_file) ZEND_PARSE_PARAMETERS_END(); if (filename_len == 0) { - php_error_docref(NULL, E_WARNING, "Filename cannot be empty!"); - RETURN_FALSE; + zend_value_error("Filename cannot be empty!"); + return; } /* Set callback function */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index dd93adebb5efa..6e045fade74b1 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -361,7 +361,7 @@ function is_uploaded_file(string $path): bool {} function move_uploaded_file(string $path, string $new_path): bool {} -function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array {} +function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {} function parse_ini_string(string $ini_string, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {} From c30e2348839ab7bb4ea4ff7c793b9b501d15ad08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:20:02 +0100 Subject: [PATCH 04/21] Promote warnings to exceptions in dl() function --- ext/standard/dl.c | 10 +++++----- .../tests/general_functions/dl-check-enabled.phpt | 14 ++++++++------ .../tests/general_functions/dl-cve-2007-4887.phpt | 9 ++++++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ext/standard/dl.c b/ext/standard/dl.c index 1edfb944fc403..efe6ea8182c8b 100644 --- a/ext/standard/dl.c +++ b/ext/standard/dl.c @@ -50,13 +50,13 @@ PHPAPI PHP_FUNCTION(dl) ZEND_PARSE_PARAMETERS_END(); if (!PG(enable_dl)) { - php_error_docref(NULL, E_WARNING, "Dynamically loaded extensions aren't enabled"); - RETURN_FALSE; + zend_throw_error(NULL, "Dynamically loaded extensions aren't enabled"); + return; } if (filename_len >= MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "File name exceeds the maximum allowed length of %d characters", MAXPATHLEN); - RETURN_FALSE; + zend_value_error("File name exceeds the maximum allowed length of %d characters", MAXPATHLEN); + return; } php_dl(filename, MODULE_TEMPORARY, return_value, 0); @@ -265,7 +265,7 @@ PHP_MINFO_FUNCTION(dl) PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now) { - php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", file); + zend_throw_error(NULL, "Cannot dynamically load %s - dynamic modules are not supported", file); RETVAL_FALSE; } diff --git a/ext/standard/tests/general_functions/dl-check-enabled.phpt b/ext/standard/tests/general_functions/dl-check-enabled.phpt index 7559b8d905c90..57cf49078d99a 100644 --- a/ext/standard/tests/general_functions/dl-check-enabled.phpt +++ b/ext/standard/tests/general_functions/dl-check-enabled.phpt @@ -1,6 +1,6 @@ --TEST-- dl() returns false when disabled via INI settings -+--CREDITS-- +--CREDITS-- Tom Van Herreweghe User Group: PHP-WVL & PHPGent #PHPTestFest --SKIPIF-- @@ -14,9 +14,11 @@ if (!in_array(php_sapi_name(), $enabled_sapi)) { enable_dl=0 --FILE-- getMessage() . "\n"; +} ?> ---EXPECTF-- - -Warning: dl(): Dynamically loaded extensions aren't enabled in %s on line %d -bool(false) +--EXPECT-- +Dynamically loaded extensions aren't enabled diff --git a/ext/standard/tests/general_functions/dl-cve-2007-4887.phpt b/ext/standard/tests/general_functions/dl-cve-2007-4887.phpt index 263c9a6def492..08cc33aa16ea8 100644 --- a/ext/standard/tests/general_functions/dl-cve-2007-4887.phpt +++ b/ext/standard/tests/general_functions/dl-cve-2007-4887.phpt @@ -11,8 +11,11 @@ if (!in_array(php_sapi_name(), $enabled_sapi)) { enable_dl=1 --FILE-- getMessage() . "\n"; +} ?> --EXPECTF-- -Warning: dl(): File name exceeds the maximum allowed length of %d characters in %s on line %d -bool(false) +File name exceeds the maximum allowed length of %d characters From 9b4cf611dc7a70566c0cceeb41b12224ed10b0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:21:06 +0100 Subject: [PATCH 05/21] Promote warnings to exceptions in password_*() functions --- ext/standard/password.c | 14 ++--- .../password/password_bcrypt_errors.phpt | 23 ++++---- .../tests/password/password_hash_error.phpt | 10 ++-- .../password/password_hash_error_argon2.phpt | 58 ++++++++++++------- 4 files changed, 64 insertions(+), 41 deletions(-) diff --git a/ext/standard/password.c b/ext/standard/password.c index 17896e77ee6fa..61a5b725bde78 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -83,7 +83,7 @@ static zend_string* php_password_make_salt(size_t length) /* {{{ */ zend_string *ret, *buffer; if (length > (INT_MAX / 3)) { - php_error_docref(NULL, E_WARNING, "Length is too large to safely generate"); + zend_value_error("Length is too large to safely generate"); return NULL; } @@ -193,7 +193,7 @@ static zend_string* php_password_bcrypt_hash(const zend_string *password, zend_a } if (cost < 4 || cost > 31) { - php_error_docref(NULL, E_WARNING, "Invalid bcrypt cost parameter specified: " ZEND_LONG_FMT, cost); + zend_value_error("Invalid bcrypt cost parameter specified: " ZEND_LONG_FMT, cost); return NULL; } @@ -316,7 +316,7 @@ static zend_string *php_password_argon2_hash(const zend_string *password, zend_a } if (memory_cost > ARGON2_MAX_MEMORY || memory_cost < ARGON2_MIN_MEMORY) { - php_error_docref(NULL, E_WARNING, "Memory cost is outside of allowed memory range"); + zend_value_error("Memory cost is outside of allowed memory range"); return NULL; } @@ -325,7 +325,7 @@ static zend_string *php_password_argon2_hash(const zend_string *password, zend_a } if (time_cost > ARGON2_MAX_TIME || time_cost < ARGON2_MIN_TIME) { - php_error_docref(NULL, E_WARNING, "Time cost is outside of allowed time range"); + zend_value_error("Time cost is outside of allowed time range"); return NULL; } @@ -334,7 +334,7 @@ static zend_string *php_password_argon2_hash(const zend_string *password, zend_a } if (threads > ARGON2_MAX_LANES || threads == 0) { - php_error_docref(NULL, E_WARNING, "Invalid number of threads"); + zend_value_error("Invalid number of threads"); return NULL; } @@ -669,9 +669,9 @@ PHP_FUNCTION(password_hash) algo = php_password_algo_find_zval(zalgo); if (!algo) { zend_string *algostr = zval_get_string(zalgo); - php_error_docref(NULL, E_WARNING, "Unknown password hashing algorithm: %s", ZSTR_VAL(algostr)); + zend_value_error("Unknown password hashing algorithm: %s", ZSTR_VAL(algostr)); zend_string_release(algostr); - RETURN_NULL(); + return; } digest = algo->hash(password, options); diff --git a/ext/standard/tests/password/password_bcrypt_errors.phpt b/ext/standard/tests/password/password_bcrypt_errors.phpt index 64496744cb1a9..10c3483f5a80d 100644 --- a/ext/standard/tests/password/password_bcrypt_errors.phpt +++ b/ext/standard/tests/password/password_bcrypt_errors.phpt @@ -3,15 +3,18 @@ Test error operation of password_hash() with bcrypt hashing --FILE-- 3)); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 3))); - -var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 32))); - +try { + var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 32))); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} ?> ---EXPECTF-- -Warning: password_hash(): Invalid bcrypt cost parameter specified: 3 in %s on line %d -NULL - -Warning: password_hash(): Invalid bcrypt cost parameter specified: 32 in %s on line %d -NULL +--EXPECT-- +Invalid bcrypt cost parameter specified: 3 +Invalid bcrypt cost parameter specified: 32 diff --git a/ext/standard/tests/password/password_hash_error.phpt b/ext/standard/tests/password/password_hash_error.phpt index cb50654905907..a0d8c6461e71f 100644 --- a/ext/standard/tests/password/password_hash_error.phpt +++ b/ext/standard/tests/password/password_hash_error.phpt @@ -10,7 +10,11 @@ try { echo $e->getMessage(), "\n"; } -var_dump(password_hash("foo", array())); +try { + password_hash("foo", array()); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} try { var_dump(password_hash("foo", 19, new StdClass)); @@ -35,9 +39,7 @@ try { password_hash() expects at least 2 parameters, 1 given Warning: Array to string conversion in %s on line %d - -Warning: password_hash(): Unknown password hashing algorithm: Array in %s on line %d -NULL +Unknown password hashing algorithm: Array password_hash() expects parameter 3 to be array, object given password_hash() expects parameter 3 to be array, string given password_hash() expects parameter 1 to be string, array given diff --git a/ext/standard/tests/password/password_hash_error_argon2.phpt b/ext/standard/tests/password/password_hash_error_argon2.phpt index 2ea6b93627c0f..0fdb0c2ba83e4 100644 --- a/ext/standard/tests/password/password_hash_error_argon2.phpt +++ b/ext/standard/tests/password/password_hash_error_argon2.phpt @@ -7,28 +7,46 @@ if (!defined('PASSWORD_ARGON2ID')) die('skip password_hash not built with Argon2 ?> --FILE-- 0])); -var_dump(password_hash('test', PASSWORD_ARGON2I, ['time_cost' => 0])); -var_dump(password_hash('test', PASSWORD_ARGON2I, ['threads' => 0])); -var_dump(password_hash('test', PASSWORD_ARGON2ID, ['memory_cost' => 0])); -var_dump(password_hash('test', PASSWORD_ARGON2ID, ['time_cost' => 0])); -var_dump(password_hash('test', PASSWORD_ARGON2ID, ['threads' => 0])); -?> ---EXPECTF-- -Warning: password_hash(): Memory cost is outside of allowed memory range in %s on line %d -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2I, ['memory_cost' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2I, ['time_cost' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: password_hash(): %sthread%s -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2I, ['threads' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: password_hash(): Memory cost is outside of allowed memory range in %s on line %d -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2ID, ['memory_cost' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2ID, ['time_cost' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: password_hash(): %sthread%s -NULL +try { + var_dump(password_hash('test', PASSWORD_ARGON2ID, ['threads' => 0])); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +?> +--EXPECT-- +Memory cost is outside of allowed memory range +Time cost is outside of allowed time range +Invalid number of threads +Memory cost is outside of allowed memory range +Time cost is outside of allowed time range +Invalid number of threads From 7adf0cef36e13e7095154d20c5b6a13e266b725e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:22:28 +0100 Subject: [PATCH 06/21] Promote warning to exception in get_browser() function --- ext/standard/browscap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 8e99b925dbafd..980719fa0b3e7 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -701,8 +701,8 @@ PHP_FUNCTION(get_browser) } } else { if (!global_bdata.htab) { - php_error_docref(NULL, E_WARNING, "browscap ini directive not set"); - RETURN_FALSE; + zend_throw_error(NULL, "Browscap ini directive not set"); + return; } bdata = &global_bdata; } From b550ea3fc44d4127d5fcf56becc582ec552f1c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:22:44 +0100 Subject: [PATCH 07/21] Promote warning to exception in dns_check_record() function --- ext/standard/dns.c | 4 ++-- ext/standard/dns_win32.c | 4 ++-- ext/standard/tests/network/bug41347.phpt | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/standard/dns.c b/ext/standard/dns.c index c3a9b9cde66ab..d46226aafd1d3 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -383,8 +383,8 @@ PHP_FUNCTION(dns_check_record) ZEND_PARSE_PARAMETERS_END(); if (hostname_len == 0) { - php_error_docref(NULL, E_WARNING, "Host cannot be empty"); - RETURN_FALSE; + zend_value_error("Host cannot be empty"); + return; } if (rectype) { diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index 5dc39a104ba0a..1221cbb6fb77b 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -107,8 +107,8 @@ PHP_FUNCTION(dns_check_record) } if (hostname_len == 0) { - php_error_docref(NULL, E_WARNING, "Host cannot be empty"); - RETURN_FALSE; + zend_value_error("Host cannot be empty"); + return; } if (rectype) { diff --git a/ext/standard/tests/network/bug41347.phpt b/ext/standard/tests/network/bug41347.phpt index 6ece098191de5..6390327a52bef 100644 --- a/ext/standard/tests/network/bug41347.phpt +++ b/ext/standard/tests/network/bug41347.phpt @@ -2,8 +2,11 @@ dns_check_record() segfault with empty host --FILE-- getMessage() . "\n"; +} ?> ---EXPECTF-- -Warning: dns_check_record(): Host cannot be empty in %s on line %d -bool(false) +--EXPECT-- +Host cannot be empty From 716c6772673263689cec3ec7e632ef4a32a0c057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:25:42 +0100 Subject: [PATCH 08/21] Promote warning to exception in convert_uudecode() function --- ext/standard/tests/strings/uuencode.phpt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/standard/tests/strings/uuencode.phpt b/ext/standard/tests/strings/uuencode.phpt index 8199a2ed0571b..f7d864bdfa44d 100644 --- a/ext/standard/tests/strings/uuencode.phpt +++ b/ext/standard/tests/strings/uuencode.phpt @@ -10,7 +10,11 @@ var_dump(convert_uudecode("!@#$%^YUGFDFGHJKLUYTFBNMLOYT")); var_dump(convert_uudecode($enc)); var_dump($enc = convert_uuencode("not very sophisticated")); var_dump(convert_uudecode($enc)); -var_dump(convert_uudecode(substr($enc, 0, -10))); +try { + convert_uudecode(substr($enc, 0, -10)); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> @@ -26,7 +30,5 @@ string(36) "6;F]T('9E Date: Wed, 20 Nov 2019 02:26:39 +0100 Subject: [PATCH 09/21] Promote warnings to exceptions in settype() function --- Zend/tests/settype_resource.phpt | Bin 1579 -> 1190 bytes .../gettype_settype_basic.phpt | 106 ++----- .../gettype_settype_error.phpt | 12 +- .../gettype_settype_variation5.phpt | 263 ++++++------------ .../tests/general_functions/type.phpt | 33 +-- ext/standard/type.c | 6 +- 6 files changed, 135 insertions(+), 285 deletions(-) diff --git a/Zend/tests/settype_resource.phpt b/Zend/tests/settype_resource.phpt index a6721cb7572a2b4964a3eb7d650bb83b041594ca..1b038613f33520e50c6f0661574896ce5314f243 100644 GIT binary patch delta 359 zcmYj~O-sW-5QZ(*LYKB)^lF!-hYe_HF&`D7(1W+?LC}+zHB8e$%$C`W7)t1m$bS&T zi$Brb#0BRxJkLAtd=EbRKaZUQHKVbld(yY70$Gv*y&W}o@ucuI}mT>KXtWCK;MH>A_4BvDP=D?Go4)%t?IYVbuEs^ zXGCdC^Mr>UW$ns{73WSwMl7Ph_k*xCBWGsDwCL2Kxj{!Rmgbt@ETS;*1Fz{EkWD6q z=CkR%1tTI5MafOmo>Wby4!SG*e@I@X%=kuR3fy%=G!}oLM;@Nm>-OsFWNfeMVejG> Dt7Kw0 literal 1579 zcmb`H-)q}25Xbjw{S}9ofDG}l^RsK$_MuB*5JsUH8?3`9w!C<_l9A+&Qu@E|PEH#3 zt{2_;WPP~%>U3$kUEgohl$FA|M*W7WscUJZa_}TfBX+H{;4~O%b#F=uy`{gbbndy6 zJYi{i`(?96z^ChO-!V2aa0#{Uq~b+ETSYN}*u=>NV`VEW(xi3p!lJrYrE9bTC<>?V zok1{9XeTn#^+rLQXYmD#UfC;hHFA~w>yIOAgy~rf31h@FXHjfDAfBLmwpz^Ri>3Gd z@{p1Fc(z(D<_q+)4|#@WIGenA`D8ko(Pu4ME73aBlll5>vq3X5v}i`9)Y?ctV8{5VJWxJp3R;Ga6jr!B=}sC4!2k1QRh37xzj MSHKTlL(_@<19~0v%K!iX diff --git a/ext/standard/tests/general_functions/gettype_settype_basic.phpt b/ext/standard/tests/general_functions/gettype_settype_basic.phpt index fac0327ad5181..80d12588e1dc9 100644 --- a/ext/standard/tests/general_functions/gettype_settype_basic.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_basic.phpt @@ -93,14 +93,19 @@ foreach ($types as $type) { $loop_count = 1; foreach ($values as $var) { echo "-- Iteration $loop_count --\n"; $loop_count ++; - // set to new type - var_dump( settype($var, $type) ); - // dump the var - var_dump( $var ); + try { + // set to new type + var_dump( settype($var, $type) ); - // check the new type - var_dump( gettype($var) ); + // dump the var + var_dump( $var ); + + // check the new type + var_dump( gettype($var) ); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } @@ -539,94 +544,33 @@ string(7) "boolean" -- Setting type of data to resource -- -- Iteration 1 -- -2: settype(): Cannot convert to resource type -bool(false) -array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) -} -string(5) "array" +Cannot convert to resource type -- Iteration 2 -- -2: settype(): Cannot convert to resource type -bool(false) -string(14) "another string" -string(6) "string" +Cannot convert to resource type -- Iteration 3 -- -2: settype(): Cannot convert to resource type -bool(false) -array(3) { - [0]=> - int(2) - [1]=> - int(3) - [2]=> - int(4) -} -string(5) "array" +Cannot convert to resource type -- Iteration 4 -- -2: settype(): Cannot convert to resource type -bool(false) -int(1) -string(7) "integer" +Cannot convert to resource type -- Iteration 5 -- -2: settype(): Cannot convert to resource type -bool(false) -int(-20) -string(7) "integer" +Cannot convert to resource type -- Iteration 6 -- -2: settype(): Cannot convert to resource type -bool(false) -float(2.54) -string(6) "double" +Cannot convert to resource type -- Iteration 7 -- -2: settype(): Cannot convert to resource type -bool(false) -float(-2.54) -string(6) "double" +Cannot convert to resource type -- Iteration 8 -- -2: settype(): Cannot convert to resource type -bool(false) -NULL -string(4) "NULL" +Cannot convert to resource type -- Iteration 9 -- -2: settype(): Cannot convert to resource type -bool(false) -bool(false) -string(7) "boolean" +Cannot convert to resource type -- Iteration 10 -- -2: settype(): Cannot convert to resource type -bool(false) -string(11) "some string" -string(6) "string" +Cannot convert to resource type -- Iteration 11 -- -2: settype(): Cannot convert to resource type -bool(false) -string(6) "string" -string(6) "string" +Cannot convert to resource type -- Iteration 12 -- -2: settype(): Cannot convert to resource type -bool(false) -resource(%d) of type (stream) -string(8) "resource" +Cannot convert to resource type -- Iteration 13 -- -2: settype(): Cannot convert to resource type -bool(false) -resource(%d) of type (stream) -string(8) "resource" +Cannot convert to resource type -- Iteration 14 -- -2: settype(): Cannot convert to resource type -bool(false) -object(point)#1 (2) { - ["x"]=> - int(10) - ["y"]=> - int(20) -} -string(6) "object" +Cannot convert to resource type -- Setting type of data to array -- -- Iteration 1 -- diff --git a/ext/standard/tests/general_functions/gettype_settype_error.phpt b/ext/standard/tests/general_functions/gettype_settype_error.phpt index e204c64d4c7bd..e310f9e0ac3fe 100644 --- a/ext/standard/tests/general_functions/gettype_settype_error.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_error.phpt @@ -16,15 +16,17 @@ echo "**** Testing gettype() and settype() functions ****\n"; echo "\n*** Testing settype(): error conditions ***\n"; // passing an invalid type to set -var_dump( settype( $var, "unknown" ) ); +try { + settype( $var, "unknown" ); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- **** Testing gettype() and settype() functions **** *** Testing settype(): error conditions *** - -Warning: settype(): Invalid type in %s on line %d -bool(false) +Invalid type Done diff --git a/ext/standard/tests/general_functions/gettype_settype_variation5.phpt b/ext/standard/tests/general_functions/gettype_settype_variation5.phpt index 6437baa10b3b3..f9f0059bfa44d 100644 --- a/ext/standard/tests/general_functions/gettype_settype_variation5.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_variation5.phpt @@ -24,17 +24,6 @@ precision=14 dump the variable to see its new data get the new type of the variable */ - -/* function to handle catchable errors */ -function foo($errno, $errstr, $errfile, $errline) { -// var_dump($errstr); - // print error no and error string - echo "$errno: $errstr\n"; -} -//set the error handler, this is required as -// settype() would fail with catachable fatal error -set_error_handler("foo"); - $var1 = "another string"; $var2 = array(2,3,4); @@ -63,7 +52,7 @@ $var_values = array ( true, /* strings */ - "\xFF", + "\$", "\x66", "\0123", "", @@ -159,286 +148,246 @@ foreach ($var_values as $var) { // get the current data type var_dump( gettype($var) ); - // convert it to null - var_dump( settype($var, $type) ); + // convert it to resource + try { + var_dump(settype($var, $type)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } // dump the converted data - var_dump( $var ); + var_dump($var); // check the new type after conversion - var_dump( gettype($var) ); + var_dump(gettype($var)); } echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- *** Testing gettype() & settype() functions : usage variations *** -- Setting type of data to resource -- -- Iteration 1 -- string(4) "NULL" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type NULL string(4) "NULL" -- Iteration 2 -- string(7) "boolean" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type bool(false) string(7) "boolean" -- Iteration 3 -- string(7) "boolean" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type bool(true) string(7) "boolean" -- Iteration 4 -- string(7) "boolean" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type bool(true) string(7) "boolean" -- Iteration 5 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) -string(1) "�" +Cannot convert to resource type +string(1) "$" string(6) "string" -- Iteration 6 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(1) "f" string(6) "string" -- Iteration 7 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) " 3" string(6) "string" -- Iteration 8 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(0) "" string(6) "string" -- Iteration 9 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(0) "" string(6) "string" -- Iteration 10 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(1) " " string(6) "string" -- Iteration 11 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(1) " " string(6) "string" -- Iteration 12 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) "10" string(6) "string" -- Iteration 13 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) "10" string(6) "string" -- Iteration 14 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(8) "10string" string(6) "string" -- Iteration 15 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(8) "10string" string(6) "string" -- Iteration 16 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(1) "1" string(6) "string" -- Iteration 17 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) "-1" string(6) "string" -- Iteration 18 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(3) "1e2" string(6) "string" -- Iteration 19 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) " 1" string(6) "string" -- Iteration 20 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(22) "2974394749328742328432" string(6) "string" -- Iteration 21 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "-1e-2" string(6) "string" -- Iteration 22 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(1) "1" string(6) "string" -- Iteration 23 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) "-1" string(6) "string" -- Iteration 24 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(3) "1e2" string(6) "string" -- Iteration 25 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(2) " 1" string(6) "string" -- Iteration 26 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(22) "2974394749328742328432" string(6) "string" -- Iteration 27 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "-1e-2" string(6) "string" -- Iteration 28 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(4) "0xff" string(6) "string" -- Iteration 29 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(4) "0x55" string(6) "string" -- Iteration 30 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "0XA55" string(6) "string" -- Iteration 31 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "0X123" string(6) "string" -- Iteration 32 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(4) "0123" string(6) "string" -- Iteration 33 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(4) "0123" string(6) "string" -- Iteration 34 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "-0123" string(6) "string" -- Iteration 35 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "+0123" string(6) "string" -- Iteration 36 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "-0123" string(6) "string" -- Iteration 37 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(5) "+0123" string(6) "string" -- Iteration 38 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(8) "-0x80001" string(6) "string" -- Iteration 39 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(8) "+0x80001" string(6) "string" -- Iteration 40 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(10) "-0x80001.5" string(6) "string" -- Iteration 41 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(9) "0x80001.5" string(6) "string" -- Iteration 42 -- string(6) "string" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type string(12) "@$%#$%^$%^&^" string(6) "string" -- Iteration 43 -- string(5) "array" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type array(0) { } string(5) "array" -- Iteration 44 -- string(5) "array" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type array(1) { [0]=> NULL @@ -446,8 +395,7 @@ array(1) { string(5) "array" -- Iteration 45 -- string(5) "array" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type array(4) { [0]=> int(1) @@ -461,8 +409,7 @@ array(4) { string(5) "array" -- Iteration 46 -- string(5) "array" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type array(4) { [1]=> string(3) "one" @@ -476,8 +423,7 @@ array(4) { string(5) "array" -- Iteration 47 -- string(5) "array" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type array(3) { [0]=> float(1.5) @@ -489,176 +435,147 @@ array(3) { string(5) "array" -- Iteration 48 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-2147483648) string(6) "double" -- Iteration 49 -- string(7) "integer" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type int(2147483647) string(7) "integer" -- Iteration 50 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(2147483649) string(6) "double" -- Iteration 51 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(1232147483649) string(6) "double" -- Iteration 52 -- string(7) "integer" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type int(85) string(7) "integer" -- Iteration 53 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(1058513956921) string(6) "double" -- Iteration 54 -- string(7) "integer" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type int(-21903) string(7) "integer" -- Iteration 55 -- string(7) "integer" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type int(365) string(7) "integer" -- Iteration 56 -- string(7) "integer" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type int(-365) string(7) "integer" -- Iteration 57 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(80561044571754) string(6) "double" -- Iteration 58 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(100000) string(6) "double" -- Iteration 59 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-100000) string(6) "double" -- Iteration 60 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(100000) string(6) "double" -- Iteration 61 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-100000) string(6) "double" -- Iteration 62 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-1.5) string(6) "double" -- Iteration 63 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(0.5) string(6) "double" -- Iteration 64 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-0.5) string(6) "double" -- Iteration 65 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(500000) string(6) "double" -- Iteration 66 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-500000) string(6) "double" -- Iteration 67 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-5.0E-7) string(6) "double" -- Iteration 68 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(500000) string(6) "double" -- Iteration 69 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-500000) string(6) "double" -- Iteration 70 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(512000) string(6) "double" -- Iteration 71 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-512000) string(6) "double" -- Iteration 72 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(5.12E-7) string(6) "double" -- Iteration 73 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(5.12E-7) string(6) "double" -- Iteration 74 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(512000) string(6) "double" -- Iteration 75 -- string(6) "double" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type float(-512000) string(6) "double" -- Iteration 76 -- string(6) "object" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type object(point)#1 (2) { ["x"]=> NULL @@ -668,8 +585,7 @@ object(point)#1 (2) { string(6) "object" -- Iteration 77 -- string(6) "object" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type object(point)#2 (2) { ["x"]=> float(2.5) @@ -679,8 +595,7 @@ object(point)#2 (2) { string(6) "object" -- Iteration 78 -- string(6) "object" -2: settype(): Cannot convert to resource type -bool(false) +Cannot convert to resource type object(point)#3 (2) { ["x"]=> int(0) diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt index 0b460b08d1e7a..342b353baf782 100644 --- a/ext/standard/tests/general_functions/type.phpt +++ b/ext/standard/tests/general_functions/type.phpt @@ -160,8 +160,7 @@ bool(true) bool(true) bool(true) bool(true) -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type array(3) { [0]=> int(1) @@ -170,11 +169,9 @@ array(3) { [2]=> int(3) } -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type string(14) "another string" -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type array(3) { [0]=> int(2) @@ -183,29 +180,21 @@ array(3) { [2]=> int(4) } -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type int(1) -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type float(2) -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type NULL -string(42) "settype(): Cannot convert to resource type" -bool(false) -bool(false) -string(42) "settype(): Cannot convert to resource type" +Error: Cannot convert to resource type bool(false) +Error: Cannot convert to resource type string(11) "some string" -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type resource(%d) of type (Unknown) -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type resource(%d) of type (stream) -string(42) "settype(): Cannot convert to resource type" -bool(false) +Error: Cannot convert to resource type object(stdClass)#%d (0) { } bool(true) diff --git a/ext/standard/type.c b/ext/standard/type.c index af847bf352ce1..b794937b881bf 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -82,11 +82,11 @@ PHP_FUNCTION(settype) zval_ptr_dtor(&tmp); } if (zend_string_equals_literal_ci(type, "resource")) { - php_error_docref(NULL, E_WARNING, "Cannot convert to resource type"); + zend_value_error("Cannot convert to resource type"); } else { - php_error_docref(NULL, E_WARNING, "Invalid type"); + zend_value_error("Invalid type"); } - RETURN_FALSE; + return; } if (ptr == &tmp) { From 2895a860669d2893a16139d9bb9952b9660e6503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:27:46 +0100 Subject: [PATCH 10/21] Promote warrnings to exceptions in chgrp() function --- ext/standard/filestat.c | 4 ++-- ext/standard/tests/file/chgrp.phpt | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index f2514d16d2887..8dbfcaace4332 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -354,7 +354,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */ option = PHP_STREAM_META_GROUP_NAME; value = Z_STRVAL_P(group); } else { - php_error_docref(NULL, E_WARNING, "parameter 2 should be string or int, %s given", zend_zval_type_name(group)); + zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group)); RETURN_FALSE; } if(wrapper->wops->stream_metadata(wrapper, filename, option, value, NULL)) { @@ -383,7 +383,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */ RETURN_FALSE; } } else { - php_error_docref(NULL, E_WARNING, "parameter 2 should be string or int, %s given", zend_zval_type_name(group)); + zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group)); RETURN_FALSE; } diff --git a/ext/standard/tests/file/chgrp.phpt b/ext/standard/tests/file/chgrp.phpt index 03ea24141bb0a..9003979a7526e 100644 --- a/ext/standard/tests/file/chgrp.phpt +++ b/ext/standard/tests/file/chgrp.phpt @@ -7,9 +7,11 @@ if(substr(PHP_OS, 0, 3) == "WIN") ?> --FILE-- getMessage() . "\n"; +} ?> --EXPECTF-- -Warning: chgrp(): parameter 2 should be string or int, null given in %schgrp.php on line 2 -ALIVE +Parameter 2 should be string or int, null given From 174cb29efb48299978b7e01e4b67e3d16068fdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:28:46 +0100 Subject: [PATCH 11/21] Promote warning to exception in constant() function --- Zend/tests/018.phpt | 18 +++++++++++++----- Zend/tests/bug51791.phpt | 11 +++++++---- ext/standard/basic_functions.c | 2 +- .../tests/general_functions/bug72920.phpt | 11 +++++++---- tests/classes/constants_visibility_002.phpt | 11 +++++++---- tests/classes/constants_visibility_003.phpt | 12 +++++++----- tests/lang/bug44827.phpt | 10 ++++++---- 7 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Zend/tests/018.phpt b/Zend/tests/018.phpt index 97e53b105008f..f0610e47c7e47 100644 --- a/Zend/tests/018.phpt +++ b/Zend/tests/018.phpt @@ -3,10 +3,19 @@ constant() tests --FILE-- getMessage() . "\n"; +} + +try { + constant('::'); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} define("TEST_CONST2", "test"); var_dump(constant("TEST_CONST2")); @@ -14,8 +23,7 @@ var_dump(constant("TEST_CONST2")); echo "Done\n"; ?> --EXPECTF-- -Warning: constant(): Couldn't find constant in %s on line %d -NULL -int(1) +Couldn't find constant +Couldn't find constant :: string(4) "test" Done diff --git a/Zend/tests/bug51791.phpt b/Zend/tests/bug51791.phpt index 0b92fa8c62592..817321e6b7afa 100644 --- a/Zend/tests/bug51791.phpt +++ b/Zend/tests/bug51791.phpt @@ -6,9 +6,12 @@ Bug #51791 (constant() failed to check undefined constant and php interpreter st class A { const B = 1; } -var_dump(constant('A::B1')); +try { + constant('A::B1'); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} ?> ---EXPECTF-- -Warning: constant(): Couldn't find constant A::B1 in %s on line %d -NULL +--EXPECT-- +Couldn't find constant A::B1 diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 52bfc537c9e43..767813a9b6d04 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2040,7 +2040,7 @@ PHP_FUNCTION(constant) } } else { if (!EG(exception)) { - php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", ZSTR_VAL(const_name)); + zend_value_error("Couldn't find constant %s", ZSTR_VAL(const_name)); } RETURN_NULL(); } diff --git a/ext/standard/tests/general_functions/bug72920.phpt b/ext/standard/tests/general_functions/bug72920.phpt index 8ba4d26713626..ab0159596eabf 100644 --- a/ext/standard/tests/general_functions/bug72920.phpt +++ b/ext/standard/tests/general_functions/bug72920.phpt @@ -6,7 +6,10 @@ class Foo { private const C1 = "a"; } -var_dump(constant('Foo::C1')); ---EXPECTF-- -Warning: constant(): Couldn't find constant Foo::C1 in %s on line %d -NULL +try { + constant('Foo::C1'); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +--EXPECT-- +Couldn't find constant Foo::C1 diff --git a/tests/classes/constants_visibility_002.phpt b/tests/classes/constants_visibility_002.phpt index 4e0ecb1aa23b8..aa9d9bed35cba 100644 --- a/tests/classes/constants_visibility_002.phpt +++ b/tests/classes/constants_visibility_002.phpt @@ -14,11 +14,14 @@ class A { A::staticConstDump(); (new A())->constDump(); -constant('A::protectedConst'); +try { + constant('A::protectedConst'); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} ?> ---EXPECTF-- +--EXPECT-- string(14) "protectedConst" string(14) "protectedConst" - -Warning: constant(): Couldn't find constant A::protectedConst in %s on line %d +Couldn't find constant A::protectedConst diff --git a/tests/classes/constants_visibility_003.phpt b/tests/classes/constants_visibility_003.phpt index 7c961695ed6ce..caa135f4e4bb3 100644 --- a/tests/classes/constants_visibility_003.phpt +++ b/tests/classes/constants_visibility_003.phpt @@ -14,11 +14,13 @@ class A { A::staticConstDump(); (new A())->constDump(); -constant('A::privateConst'); - +try { + constant('A::privateConst'); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} ?> ---EXPECTF-- +--EXPECT-- string(12) "privateConst" string(12) "privateConst" - -Warning: constant(): Couldn't find constant A::privateConst in %s on line %d +Couldn't find constant A::privateConst diff --git a/tests/lang/bug44827.phpt b/tests/lang/bug44827.phpt index d871cfd2a89fc..3a1e379f50591 100644 --- a/tests/lang/bug44827.phpt +++ b/tests/lang/bug44827.phpt @@ -7,10 +7,12 @@ Testfest Munich 2009 --FILE-- getMessage() . "\n"; +} ?> --EXPECTF-- Warning: Class constants cannot be defined or redefined in %s on line %d - -Warning: constant(): Couldn't find constant :: in %s on line %d -NULL +Couldn't find constant :: From 1833afcc69aa69f87934271bac183d40212619a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:29:18 +0100 Subject: [PATCH 12/21] Promote warning to exception in file_get_contents() function --- ext/standard/file.c | 4 ++-- ext/standard/tests/file/file_get_contents_error.phpt | 11 +++++++---- .../tests/file/file_get_contents_error002.phpt | 8 ++++++-- .../file_get_contents_file_put_contents_error.phpt | 11 +++++++---- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index c7727a65b8f72..58bbbaa52c864 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -543,8 +543,8 @@ PHP_FUNCTION(file_get_contents) ZEND_PARSE_PARAMETERS_END(); if (ZEND_NUM_ARGS() == 5 && maxlen < 0) { - php_error_docref(NULL, E_WARNING, "length must be greater than or equal to zero"); - RETURN_FALSE; + zend_value_error("Length must be greater than or equal to zero"); + return; } context = php_stream_context_from_zval(zcontext, 0); diff --git a/ext/standard/tests/file/file_get_contents_error.phpt b/ext/standard/tests/file/file_get_contents_error.phpt index 9757b3be2a24c..8304105ccced5 100644 --- a/ext/standard/tests/file/file_get_contents_error.phpt +++ b/ext/standard/tests/file/file_get_contents_error.phpt @@ -20,8 +20,12 @@ print( file_get_contents("/no/such/file/or/dir") ); create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte"); $file_handle = fopen($file_path."/file_put_contents_error.tmp", "w"); -echo "\n-- Testing for invalid negative maxlen values --"; -var_dump( file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5) ); +echo "\n-- Testing for invalid negative maxlen values --\n"; +try { + file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} delete_files($file_path, 1); fclose($file_handle); @@ -47,7 +51,6 @@ if(file_exists($file_path."/file_put_contents1.tmp")) { Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d -- Testing for invalid negative maxlen values -- -Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d -bool(false) +Length must be greater than or equal to zero *** Done *** diff --git a/ext/standard/tests/file/file_get_contents_error002.phpt b/ext/standard/tests/file/file_get_contents_error002.phpt index 8ca11626723fa..4c9faf91ea171 100644 --- a/ext/standard/tests/file/file_get_contents_error002.phpt +++ b/ext/standard/tests/file/file_get_contents_error002.phpt @@ -7,7 +7,11 @@ file_get_contents() test using negative parameter for length (last parameter) display_errors=false --FILE-- getMessage() . "\n"; +} ?> --EXPECT-- -bool(false) +Length must be greater than or equal to zero diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt index a50317e8dbb31..b111ff9f5da72 100644 --- a/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt +++ b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt @@ -20,9 +20,13 @@ print( file_get_contents("/no/such/file/or/dir") ); $file_handle = fopen($file_path."/file_put_contents.tmp", "w"); -echo "\n-- Testing for invalid negative maxlen values --"; +echo "\n-- Testing for invalid negative maxlen values --\n"; file_put_contents($file_path."/file_put_contents1.tmp", "Garbage data in the file"); -var_dump( file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5) ); +try { + file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} fclose($file_handle); @@ -43,7 +47,6 @@ unlink($file_path."/file_put_contents1.tmp"); Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d -- Testing for invalid negative maxlen values -- -Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d -bool(false) +Length must be greater than or equal to zero *** Done *** From b87ecf354cbc49c411157fdb28b6c33d03ffe257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:30:48 +0100 Subject: [PATCH 13/21] Promote warnings to exceptions in proc_open() function --- ext/standard/proc_open.c | 20 ++++++------- .../general_functions/proc_open_array.phpt | 11 ++++--- .../general_functions/proc_open_pipes3.phpt | 9 ++++-- .../general_functions/proc_open_redirect.phpt | 30 ++++++++++++------- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 4906b3f828375..85bd2c9f57c8e 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -529,8 +529,8 @@ PHP_FUNCTION(proc_open) zval *arg_zv; uint32_t num_elems = zend_hash_num_elements(Z_ARRVAL_P(command_zv)); if (num_elems == 0) { - php_error_docref(NULL, E_WARNING, "Command array must have at least one element"); - RETURN_FALSE; + zend_value_error("Command array must have at least one element"); + return; } #ifdef PHP_WIN32 @@ -622,7 +622,7 @@ PHP_FUNCTION(proc_open) zval *ztype; if (str_index) { - php_error_docref(NULL, E_WARNING, "descriptor spec must be an integer indexed array"); + zend_value_error("Descriptor spec must be an integer indexed array"); goto exit_fail; } @@ -655,7 +655,7 @@ PHP_FUNCTION(proc_open) descriptors[ndesc].mode = DESC_FILE; } else if (Z_TYPE_P(descitem) != IS_ARRAY) { - php_error_docref(NULL, E_WARNING, "Descriptor item must be either an array or a File-Handle"); + zend_value_error("Descriptor item must be either an array or a File-Handle"); goto exit_fail; } else { @@ -664,7 +664,7 @@ PHP_FUNCTION(proc_open) goto exit_fail; } } else { - php_error_docref(NULL, E_WARNING, "Missing handle qualifier in array"); + zend_value_error("Missing handle qualifier in array"); goto exit_fail; } @@ -677,7 +677,7 @@ PHP_FUNCTION(proc_open) goto exit_fail; } } else { - php_error_docref(NULL, E_WARNING, "Missing mode parameter for 'pipe'"); + zend_value_error("Missing mode parameter for 'pipe'"); goto exit_fail; } @@ -718,7 +718,7 @@ PHP_FUNCTION(proc_open) goto exit_fail; } } else { - php_error_docref(NULL, E_WARNING, "Missing file name parameter for 'file'"); + zend_value_error("Missing file name parameter for 'file'"); goto exit_fail; } @@ -727,7 +727,7 @@ PHP_FUNCTION(proc_open) goto exit_fail; } } else { - php_error_docref(NULL, E_WARNING, "Missing mode parameter for 'file'"); + zend_value_error("Missing mode parameter for 'file'"); goto exit_fail; } @@ -760,11 +760,11 @@ PHP_FUNCTION(proc_open) php_file_descriptor_t childend; if (!ztarget) { - php_error_docref(NULL, E_WARNING, "Missing redirection target"); + zend_value_error("Missing redirection target"); goto exit_fail; } if (Z_TYPE_P(ztarget) != IS_LONG) { - php_error_docref(NULL, E_WARNING, "Redirection target must be an integer"); + zend_value_error("Redirection target must be an integer"); goto exit_fail; } diff --git a/ext/standard/tests/general_functions/proc_open_array.phpt b/ext/standard/tests/general_functions/proc_open_array.phpt index 8b42a55bacaf6..99e1cc56cb4d3 100644 --- a/ext/standard/tests/general_functions/proc_open_array.phpt +++ b/ext/standard/tests/general_functions/proc_open_array.phpt @@ -10,8 +10,12 @@ $ds = [ 2 => ['pipe', 'w'], ]; -echo "Empty command array:"; -var_dump(proc_open([], $ds, $pipes)); +echo "Empty command array:\n"; +try { + proc_open([], $ds, $pipes); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "\nNul byte in program name:"; var_dump(proc_open(["php\0oops"], $ds, $pipes)); @@ -56,8 +60,7 @@ proc_close($proc); ?> --EXPECTF-- Empty command array: -Warning: proc_open(): Command array must have at least one element in %s on line %d -bool(false) +Command array must have at least one element Nul byte in program name: Warning: proc_open(): Command array element 1 contains a null byte in %s on line %d diff --git a/ext/standard/tests/general_functions/proc_open_pipes3.phpt b/ext/standard/tests/general_functions/proc_open_pipes3.phpt index 7671b1dce1794..b83a0e1a07381 100644 --- a/ext/standard/tests/general_functions/proc_open_pipes3.phpt +++ b/ext/standard/tests/general_functions/proc_open_pipes3.phpt @@ -14,7 +14,11 @@ $spec[$i] = array('pi'); proc_open("$php -n $callee", $spec, $pipes); $spec[$i] = 1; -proc_open("$php -n $callee", $spec, $pipes); +try { + proc_open("$php -n $callee", $spec, $pipes); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $spec[$i] = array('pipe', "test"); proc_open("$php -n $callee", $spec, $pipes); @@ -28,8 +32,7 @@ echo "END\n"; ?> --EXPECTF-- Warning: proc_open(): pi is not a valid descriptor spec/mode in %s on line %d - -Warning: proc_open(): Descriptor item must be either an array or a File-Handle in %s on line %d +Descriptor item must be either an array or a File-Handle array(4) { [3]=> resource(%d) of type (Unknown) diff --git a/ext/standard/tests/general_functions/proc_open_redirect.phpt b/ext/standard/tests/general_functions/proc_open_redirect.phpt index 92da696ee9d98..bf0412c0a2f58 100644 --- a/ext/standard/tests/general_functions/proc_open_redirect.phpt +++ b/ext/standard/tests/general_functions/proc_open_redirect.phpt @@ -4,9 +4,23 @@ Redirection support in proc_open getMessage() . "\n"; +} + +try { + proc_open([$php], [['redirect', 'foo']], $pipes); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + proc_open([$php], [['redirect', 42]], $pipes); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "\nWith pipe:\n"; $cmd = [$php, '-r', 'echo "Test\n"; fprintf(STDERR, "Error");']; @@ -38,14 +52,10 @@ proc_close($proc); ?> --EXPECTF-- -Warning: proc_open(): Missing redirection target in %s on line %d -bool(false) - -Warning: proc_open(): Redirection target must be an integer in %s on line %d -bool(false) +Missing redirection target +Redirection target must be an integer -Warning: proc_open(): Redirection target 42 not found in %s on line %d -bool(false) +Warning: proc_open(): Redirection target 42 not found in %s With pipe: array(1) { From b610f2ec54811830dcca96b462a4078c097acaa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:31:49 +0100 Subject: [PATCH 14/21] Capitalize the initial letter of the error message of htmlspecialchars() function --- ext/standard/html.c | 2 +- ext/standard/tests/strings/bug44703.phpt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/standard/html.c b/ext/standard/html.c index 8a597f05f9495..b7ca69d74e844 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -452,7 +452,7 @@ static enum entity_charset determine_charset(char *charset_hint) } } if (!found) { - php_error_docref(NULL, E_WARNING, "charset `%s' not supported, assuming utf-8", + php_error_docref(NULL, E_WARNING, "Charset `%s' not supported, assuming utf-8", charset_hint); } } diff --git a/ext/standard/tests/strings/bug44703.phpt b/ext/standard/tests/strings/bug44703.phpt index 6171cee923eba..f9f0e6ea8f0f8 100644 --- a/ext/standard/tests/strings/bug44703.phpt +++ b/ext/standard/tests/strings/bug44703.phpt @@ -22,25 +22,25 @@ var_dump(htmlspecialchars("<>", ENT_COMPAT, str_repeat('a', 100))); ?> --EXPECTF-- -Warning: htmlspecialchars(): charset `1' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `1' not supported, assuming utf-8 in %s on line %d string(35) "<a href='test'>Test</a>" -Warning: htmlspecialchars(): charset `12' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `12' not supported, assuming utf-8 in %s on line %d string(35) "<a href='test'>Test</a>" -Warning: htmlspecialchars(): charset `125' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `125' not supported, assuming utf-8 in %s on line %d string(35) "<a href='test'>Test</a>" string(35) "<a href='test'>Test</a>" -Warning: htmlspecialchars(): charset `12526' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `12526' not supported, assuming utf-8 in %s on line %d string(35) "<a href='test'>Test</a>" string(8) "<>" -Warning: htmlspecialchars(): charset `8666' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `8666' not supported, assuming utf-8 in %s on line %d string(8) "<>" string(8) "<>" string(8) "<>" string(8) "<>" -Warning: htmlspecialchars(): charset `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' not supported, assuming utf-8 in %s on line %d +Warning: htmlspecialchars(): Charset `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' not supported, assuming utf-8 in %s on line %d string(8) "<>" From b2b219c02e7ff4461adb4a51cc04a2bd5411f471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:32:40 +0100 Subject: [PATCH 15/21] Promote warning to exception in the levenshtein() function --- ext/standard/levenshtein.c | 2 +- ext/standard/tests/strings/levenshtein.phpt | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index 3147c2bbe6aa5..1d65086ffdb09 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -123,7 +123,7 @@ PHP_FUNCTION(levenshtein) } if (distance < 0 && /* TODO */ ZEND_NUM_ARGS() != 3) { - php_error_docref(NULL, E_WARNING, "Argument string(s) too long"); + zend_value_error("Argument string(s) too long"); } RETURN_LONG(distance); diff --git a/ext/standard/tests/strings/levenshtein.phpt b/ext/standard/tests/strings/levenshtein.phpt index b4b7c03e7f580..f6daf694fbc05 100644 --- a/ext/standard/tests/strings/levenshtein.phpt +++ b/ext/standard/tests/strings/levenshtein.phpt @@ -56,23 +56,30 @@ $n += test_me("bug #16473", 2, "ax", "bcx"); $n += test_me("custom", -1, "111", "121", "my_levcode"); $n += test_me("lt maxlength1", 254, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu", "A"); -$n += test_me("gt maxlength1", -1, "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv", "A"); - $n += test_me("lt maxlength2", 254, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsu"); -$n += test_me("gt maxlength2", -1, "A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv"); echo ($n==0)?"all passed\n":"$n failed\n"; +try { + levenshtein("AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv", "A"); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + levenshtein("A", "AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuvwxyzAbcdefghijklmnopqrtsuv"); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(levenshtein("", "", -1, -1, -1)); var_dump(levenshtein("", "", 10, 10, 10)); ?> --EXPECTF-- Warning: levenshtein(): The general Levenshtein support is not there yet in %s on line %d - -Warning: levenshtein(): Argument string(s) too long in %s on line %d - -Warning: levenshtein(): Argument string(s) too long in %s on line %d all passed +Argument string(s) too long +Argument string(s) too long int(0) int(0) From 474bbc6bc63152d9803c9731d4ce8310ae8303e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:33:52 +0100 Subject: [PATCH 16/21] Promote warnings to exceptions in some URL and file related functions --- ext/standard/ftp_fopen_wrapper.c | 4 ++-- ext/standard/php_fopen_wrapper.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 2c01e88f4f3a6..8c58caef08e9b 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -1050,7 +1050,7 @@ static int php_stream_ftp_mkdir(php_stream_wrapper *wrapper, const char *url, in if (resource->path == NULL) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "Invalid path provided in %s", url); + zend_value_error("Invalid path provided in %s", url); } goto mkdir_errexit; } @@ -1143,7 +1143,7 @@ static int php_stream_ftp_rmdir(php_stream_wrapper *wrapper, const char *url, in if (resource->path == NULL) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "Invalid path provided in %s", url); + zend_value_error("Invalid path provided in %s", url); } goto rmdir_errexit; } diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index f525f868e468f..7d8f4ed3e1f43 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -219,7 +219,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); + zend_throw_error(NULL, "URL file-access is disabled in the server configuration"); } return NULL; } @@ -238,7 +238,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if (!strcasecmp(path, "stdin")) { if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); + zend_throw_error(NULL, "URL file-access is disabled in the server configuration"); } return NULL; } @@ -297,14 +297,14 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if (strcmp(sapi_module.name, "cli")) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP"); + zend_throw_error(NULL, "Direct access to file descriptors is only available from command-line PHP"); } return NULL; } if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { if (options & REPORT_ERRORS) { - php_error_docref(NULL, E_WARNING, "URL file-access is disabled in the server configuration"); + zend_throw_error(NULL, "URL file-access is disabled in the server configuration"); } return NULL; } From bc6bb44a4623f2d1d819ce5ccd6f634718d92d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:34:52 +0100 Subject: [PATCH 17/21] Promote warnings to exceptions in string search related functions --- ext/iconv/tests/iconv_strpos.phpt | 14 ++-- ext/mbstring/tests/bug43841.phpt | 14 ++-- ext/mbstring/tests/bug45923.phpt | 38 +++------ ext/standard/string.c | 36 ++++---- ext/standard/tests/strings/bug40754.phpt | 78 +++++++++++------- ext/standard/tests/strings/stripos_error.phpt | 24 ++++-- .../tests/strings/stripos_variation11.phpt | 64 ++++++-------- .../tests/strings/stripos_variation7.phpt | 13 +-- ext/standard/tests/strings/strpos.phpt | Bin 7940 -> 7996 bytes .../tests/strings/strripos_offset.phpt | 45 ++++++---- .../strings/strrpos_negative_offset.phpt | 17 ++-- .../tests/strings/strrpos_offset.phpt | 45 ++++++---- .../tests/strings/strrpos_variation11.phpt | 65 ++++++--------- .../tests/strings/strrpos_variation7.phpt | 12 +-- .../tests/strings/substr_count_error.phpt | 20 +++-- 15 files changed, 253 insertions(+), 232 deletions(-) diff --git a/ext/iconv/tests/iconv_strpos.phpt b/ext/iconv/tests/iconv_strpos.phpt index 92492c7244af3..9a1e5a77b6d37 100644 --- a/ext/iconv/tests/iconv_strpos.phpt +++ b/ext/iconv/tests/iconv_strpos.phpt @@ -6,17 +6,16 @@ iconv_strpos() iconv.internal_charset=ISO-8859-1 --FILE-- getMessage() . "\n"; + } if ($to_charset !== false) { var_dump(iconv_strpos($haystk, $needle, $offset, $to_charset)); } else { @@ -42,8 +41,7 @@ bool(false) bool(false) int(5) int(5) -2: %s -bool(false) +Offset not contained in string bool(false) int(7) int(7) diff --git a/ext/mbstring/tests/bug43841.phpt b/ext/mbstring/tests/bug43841.phpt index ab52eb51c94ac..5585ba3963046 100644 --- a/ext/mbstring/tests/bug43841.phpt +++ b/ext/mbstring/tests/bug43841.phpt @@ -30,7 +30,11 @@ foreach ($offsets as $i) { echo "mb_strrpos:\n"; var_dump(mb_strrpos('This is na English ta', 'a', $i)); echo "strrpos:\n"; - var_dump(strrpos('This is na English ta', 'a', $i)); + try { + var_dump(strrpos('This is na English ta', 'a', $i)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } ?> --EXPECTF-- @@ -45,9 +49,7 @@ mb_strrpos: Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d bool(false) strrpos: - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string -- Offset is -24 -- Multibyte String: @@ -60,9 +62,7 @@ mb_strrpos: Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d bool(false) strrpos: - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string -- Offset is -13 -- Multibyte String: diff --git a/ext/mbstring/tests/bug45923.phpt b/ext/mbstring/tests/bug45923.phpt index 6fc8e1db0989c..268917bbd87d0 100644 --- a/ext/mbstring/tests/bug45923.phpt +++ b/ext/mbstring/tests/bug45923.phpt @@ -10,7 +10,11 @@ function section($func, $haystack, $needle) echo "\n------- $func -----------\n\n"; foreach(array(0, 3, 6, 9, 11, 12, -1, -3, -6, -20) as $offset) { echo "> Offset: $offset\n"; - var_dump($func($haystack,$needle,$offset)); + try { + var_dump($func($haystack,$needle,$offset)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } @@ -40,9 +44,7 @@ bool(false) > Offset: 11 bool(false) > Offset: 12 - -Warning: strpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string > Offset: -1 bool(false) > Offset: -3 @@ -50,9 +52,7 @@ int(8) > Offset: -6 int(8) > Offset: -20 - -Warning: strpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string ------- mb_strpos ----------- @@ -94,9 +94,7 @@ bool(false) > Offset: 11 bool(false) > Offset: 12 - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string > Offset: -1 bool(false) > Offset: -3 @@ -104,9 +102,7 @@ int(8) > Offset: -6 int(8) > Offset: -20 - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string ------- mb_stripos ----------- @@ -148,9 +144,7 @@ bool(false) > Offset: 11 bool(false) > Offset: 12 - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string > Offset: -1 int(8) > Offset: -3 @@ -158,9 +152,7 @@ int(8) > Offset: -6 int(4) > Offset: -20 - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string ------- mb_strrpos ----------- @@ -202,9 +194,7 @@ bool(false) > Offset: 11 bool(false) > Offset: 12 - -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string > Offset: -1 int(8) > Offset: -3 @@ -212,9 +202,7 @@ int(8) > Offset: -6 int(4) > Offset: -20 - -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string ------- mb_strripos ----------- diff --git a/ext/standard/string.c b/ext/standard/string.c index a23c85c6d3632..77976229802dd 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1883,8 +1883,8 @@ PHP_FUNCTION(strpos) offset += (zend_long)ZSTR_LEN(haystack); } if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset, @@ -1919,8 +1919,8 @@ PHP_FUNCTION(stripos) offset += (zend_long)ZSTR_LEN(haystack); } if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } if (ZSTR_LEN(needle) > ZSTR_LEN(haystack)) { @@ -1961,15 +1961,15 @@ PHP_FUNCTION(strrpos) if (offset >= 0) { if ((size_t)offset > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p = ZSTR_VAL(haystack) + (size_t)offset; e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack); } else { if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p = ZSTR_VAL(haystack); @@ -2011,16 +2011,16 @@ PHP_FUNCTION(strripos) char lowered; if (offset >= 0) { if ((size_t)offset > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p = ZSTR_VAL(haystack) + (size_t)offset; e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) - 1; } else { p = ZSTR_VAL(haystack); if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } e = ZSTR_VAL(haystack) + (ZSTR_LEN(haystack) + (size_t)offset); } @@ -2039,16 +2039,16 @@ PHP_FUNCTION(strripos) if (offset >= 0) { if ((size_t)offset > ZSTR_LEN(haystack)) { zend_string_release_ex(haystack_dup, 0); - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p = ZSTR_VAL(haystack_dup) + offset; e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack); } else { if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { zend_string_release_ex(haystack_dup, 0); - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p = ZSTR_VAL(haystack_dup); @@ -5580,8 +5580,8 @@ PHP_FUNCTION(substr_count) offset += (zend_long)haystack_len; } if ((offset < 0) || ((size_t)offset > haystack_len)) { - php_error_docref(NULL, E_WARNING, "Offset not contained in string"); - RETURN_FALSE; + zend_value_error("Offset not contained in string"); + return; } p += offset; diff --git a/ext/standard/tests/strings/bug40754.phpt b/ext/standard/tests/strings/bug40754.phpt index d502bff829e27..9e409bf271175 100644 --- a/ext/standard/tests/strings/bug40754.phpt +++ b/ext/standard/tests/strings/bug40754.phpt @@ -11,16 +11,52 @@ var_dump(substr_replace("abcde", "x", $v, $v)); var_dump(strspn("abcde", "abc", $v, $v)); var_dump(strcspn("abcde", "abc", $v, $v)); -var_dump(substr_count("abcde", "abc", $v, $v)); +try { + var_dump(substr_count("abcde", "abc", $v, $v)); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(substr_compare("abcde", "abc", $v, $v)); -var_dump(stripos("abcde", "abc", $v)); -var_dump(substr_count("abcde", "abc", $v, 1)); +try { + stripos("abcde", "abc", $v); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + substr_count("abcde", "abc", $v, 1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(substr_count("abcde", "abc", 1, $v)); -var_dump(strpos("abcde", "abc", $v)); -var_dump(stripos("abcde", "abc", $v)); -var_dump(strrpos("abcde", "abc", $v)); -var_dump(strripos("abcde", "abc", $v)); + +try { + strpos("abcde", "abc", $v); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + stripos("abcde", "abc", $v); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + strrpos("abcde", "abc", $v); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + strripos("abcde", "abc", $v); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(strncmp("abcde", "abc", $v)); var_dump(chunk_split("abcde", $v, "abc")); var_dump(substr("abcde", $v, $v)); @@ -31,33 +67,19 @@ string(4) "bcde" string(6) "abcdex" bool(false) bool(false) - -Warning: substr_count(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d bool(false) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) - -Warning: substr_count(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string +Offset not contained in string Warning: substr_count(): Invalid length value in %s on line %d bool(false) - -Warning: strpos(): Offset not contained in string in %s on line %d -bool(false) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) - -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string +Offset not contained in string +Offset not contained in string +Offset not contained in string int(2) string(8) "abcdeabc" bool(false) diff --git a/ext/standard/tests/strings/stripos_error.phpt b/ext/standard/tests/strings/stripos_error.phpt index 0420bb090b268..caa93298748ab 100644 --- a/ext/standard/tests/strings/stripos_error.phpt +++ b/ext/standard/tests/strings/stripos_error.phpt @@ -9,22 +9,28 @@ Test stripos() function : error conditions echo "*** Testing stripos() function: error conditions ***\n"; -echo "\n-- Offset beyond the end of the string --"; -var_dump( stripos("Hello World", "o", 12) ); +echo "\n-- Offset beyond the end of the string --\n"; +try { + stripos("Hello World", "o", 12); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -echo "\n-- Offset before the start of the string --"; -var_dump( stripos("Hello World", "o", -12) ); +echo "\n-- Offset before the start of the string --\n"; +try { + stripos("Hello World", "o", -12); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "*** Done ***"; ?> ---EXPECTF-- +--EXPECT-- *** Testing stripos() function: error conditions *** -- Offset beyond the end of the string -- -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string -- Offset before the start of the string -- -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string *** Done *** diff --git a/ext/standard/tests/strings/stripos_variation11.phpt b/ext/standard/tests/strings/stripos_variation11.phpt index 4f002ed0ca367..7a9c9ff9a06cf 100644 --- a/ext/standard/tests/strings/stripos_variation11.phpt +++ b/ext/standard/tests/strings/stripos_variation11.phpt @@ -83,13 +83,13 @@ for($index = 0; $index < count($values); $index ++) { $haystack = $values[$index]; try { var_dump( stripos($values[$index], $values[$index]) ); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Error $e) { + echo get_class($e) . ": " . $e->getMessage(), "\n"; } try { var_dump( stripos($values[$index], $values[$index], 1) ); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Error $e) { + echo get_class($e) . ": " . $e->getMessage(), "\n"; } $counter ++; } @@ -126,70 +126,54 @@ bool(false) int(0) bool(false) -- Iteration 10 -- -stripos() expects parameter 1 to be string, array given -stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given -- Iteration 11 -- -stripos() expects parameter 1 to be string, array given -stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given -- Iteration 12 -- -stripos() expects parameter 1 to be string, array given -stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given -- Iteration 13 -- -stripos() expects parameter 1 to be string, array given -stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given -- Iteration 14 -- -stripos() expects parameter 1 to be string, array given -stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given +TypeError: stripos() expects parameter 1 to be string, array given -- Iteration 15 -- int(0) bool(false) -- Iteration 16 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 17 -- int(0) bool(false) -- Iteration 18 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 19 -- int(0) bool(false) -- Iteration 20 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 21 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 22 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 23 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 24 -- -stripos() expects parameter 1 to be string, resource given -stripos() expects parameter 1 to be string, resource given +TypeError: stripos() expects parameter 1 to be string, resource given +TypeError: stripos() expects parameter 1 to be string, resource given -- Iteration 25 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 26 -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string *** Done *** diff --git a/ext/standard/tests/strings/stripos_variation7.phpt b/ext/standard/tests/strings/stripos_variation7.phpt index a21686876d31d..d2ac6551dbe1d 100644 --- a/ext/standard/tests/strings/stripos_variation7.phpt +++ b/ext/standard/tests/strings/stripos_variation7.phpt @@ -16,19 +16,22 @@ echo "-- With empty heredoc string --\n"; $empty_string = <<getMessage() . "\n"; +} var_dump( stripos($empty_string, FALSE) ); var_dump( stripos($empty_string, NULL) ); echo "*** Done ***"; ?> ---EXPECTF-- +--EXPECT-- *** Testing stripos() function: with heredoc strings *** -- With empty heredoc string -- int(0) - -Warning: stripos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string int(0) int(0) *** Done *** diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt index 8e1a1a7472d18640676c3b83ca6993cb239f4648..2bc95a6c0a900c634d386d23a3155cf940e80c38 100644 GIT binary patch delta 235 zcmZp%+hez3nGk15QKdpPmx6-A_=qV`0WxpDyj^L|Il delta 210 zcmdmE*J8I}nb71kM#0H4{9Ka{3Q0;TXj&^M=<6%wr==CAmMGXM6qgj`q~>X8PS)p_ znH(c5C5@&cDK#y>C>5wIv8ZJ8Jz-&P5w7sWqP)z!bSseFg8X6)O)G`TALZnX6f*M^ wRErhz^AvJ2^HLR5Q@E1y^K&%P5_5`EHMwwU)5fnYGp|I$0I1u=-_Ml`0NnOK;{X5v diff --git a/ext/standard/tests/strings/strripos_offset.phpt b/ext/standard/tests/strings/strripos_offset.phpt index 7dc0ce0d61dd0..4f4ab2bea4cbf 100644 --- a/ext/standard/tests/strings/strripos_offset.phpt +++ b/ext/standard/tests/strings/strripos_offset.phpt @@ -9,25 +9,36 @@ try { echo $e->getMessage(), "\n"; } -var_dump(strripos(1024, 1024, -PHP_INT_MAX)); -var_dump(strripos(1024, "te", -PHP_INT_MAX)); -var_dump(strripos(1024, 1024, -PHP_INT_MAX-1)); -var_dump(strripos(1024, "te", -PHP_INT_MAX-1)); - -echo "Done\n"; -?> ---EXPECTF-- -strripos() expects parameter 3 to be int, float given +try { + strripos(1024, 1024, -PHP_INT_MAX); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +try { + strripos(1024, "te", -PHP_INT_MAX); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +try { + strripos(1024, 1024, -PHP_INT_MAX-1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +try { + strripos(1024, "te", -PHP_INT_MAX-1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strripos(): Offset not contained in string in %s on line %d -bool(false) +echo "Done\n"; +?> +--EXPECT-- +strripos() expects parameter 3 to be int, float given +Offset not contained in string +Offset not contained in string +Offset not contained in string +Offset not contained in string Done diff --git a/ext/standard/tests/strings/strrpos_negative_offset.phpt b/ext/standard/tests/strings/strrpos_negative_offset.phpt index 940c2274f4e7f..17560f18f7fd6 100644 --- a/ext/standard/tests/strings/strrpos_negative_offset.phpt +++ b/ext/standard/tests/strings/strrpos_negative_offset.phpt @@ -8,15 +8,22 @@ strr[i]pos() function with negative offset var_dump(strrpos("haystack", "ka", -1)); var_dump(strrpos("haystack", 'a', -3)); var_dump(strrpos("haystack", 'a', -4)); - var_dump(@strrpos("haystack", 'h', -9)); - + try { + strrpos("haystack", 'h', -9); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } var_dump(strripos("HAYSTHACk", 'ha', -9)); var_dump(strripos("HAYSTACK", 'h', -8)); var_dump(strripos("HAYSTACK", 'k', -1)); var_dump(strripos("HAYSTACK", "ka", -1)); var_dump(strripos("HAYSTACK", 'a', -3)); var_dump(strripos("HAYSTACK", 'a', -4)); - var_dump(@strripos("HAYSTACK", 'h', -9)); + try { + strripos("HAYSTACK", 'h', -9); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } ?> --EXPECT-- int(0) @@ -25,11 +32,11 @@ int(7) bool(false) int(5) int(1) -bool(false) +Offset not contained in string int(0) int(0) int(7) bool(false) int(5) int(1) -bool(false) +Offset not contained in string diff --git a/ext/standard/tests/strings/strrpos_offset.phpt b/ext/standard/tests/strings/strrpos_offset.phpt index fdff39fdb2446..213cd24c6fdb7 100644 --- a/ext/standard/tests/strings/strrpos_offset.phpt +++ b/ext/standard/tests/strings/strrpos_offset.phpt @@ -9,25 +9,36 @@ try { echo $e->getMessage(), "\n"; } -var_dump(strrpos(1024, 1024, -PHP_INT_MAX)); -var_dump(strrpos(1024, "te", -PHP_INT_MAX)); -var_dump(strrpos(1024, 1024, -PHP_INT_MAX-1)); -var_dump(strrpos(1024, "te", -PHP_INT_MAX-1)); - -echo "Done\n"; -?> ---EXPECTF-- -strrpos() expects parameter 3 to be int, float given +try { + strrpos(1024, 1024, -PHP_INT_MAX); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +try { + strrpos(1024, "te", -PHP_INT_MAX); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +try { + strrpos(1024, 1024, -PHP_INT_MAX-1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +try { + strrpos(1024, "te", -PHP_INT_MAX-1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +echo "Done\n"; +?> +--EXPECT-- +strrpos() expects parameter 3 to be int, float given +Offset not contained in string +Offset not contained in string +Offset not contained in string +Offset not contained in string Done diff --git a/ext/standard/tests/strings/strrpos_variation11.phpt b/ext/standard/tests/strings/strrpos_variation11.phpt index 2fbe78e30acd0..2f8627d5ad240 100644 --- a/ext/standard/tests/strings/strrpos_variation11.phpt +++ b/ext/standard/tests/strings/strrpos_variation11.phpt @@ -83,13 +83,14 @@ for($index = 0; $index < count($values); $index ++) { $haystack = $values[$index]; try { var_dump( strrpos($values[$index], $values[$index]) ); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Error $e) { + echo get_class($e) . ": " . $e->getMessage(), "\n"; } + try { var_dump( strrpos($values[$index], $values[$index], 1) ); - } catch (TypeError $e) { - echo $e->getMessage(), "\n"; + } catch (Error $e) { + echo get_class($e) . ": " . $e->getMessage(), "\n"; } $counter ++; } @@ -126,70 +127,54 @@ bool(false) int(0) bool(false) -- Iteration 10 -- -strrpos() expects parameter 1 to be string, array given -strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given -- Iteration 11 -- -strrpos() expects parameter 1 to be string, array given -strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given -- Iteration 12 -- -strrpos() expects parameter 1 to be string, array given -strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given -- Iteration 13 -- -strrpos() expects parameter 1 to be string, array given -strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given -- Iteration 14 -- -strrpos() expects parameter 1 to be string, array given -strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given +TypeError: strrpos() expects parameter 1 to be string, array given -- Iteration 15 -- int(0) bool(false) -- Iteration 16 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 17 -- int(0) bool(false) -- Iteration 18 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 19 -- int(0) bool(false) -- Iteration 20 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 21 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 22 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 23 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 24 -- -strrpos() expects parameter 1 to be string, resource given -strrpos() expects parameter 1 to be string, resource given +TypeError: strrpos() expects parameter 1 to be string, resource given +TypeError: strrpos() expects parameter 1 to be string, resource given -- Iteration 25 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string -- Iteration 26 -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +ValueError: Offset not contained in string *** Done *** diff --git a/ext/standard/tests/strings/strrpos_variation7.phpt b/ext/standard/tests/strings/strrpos_variation7.phpt index d5aa8b561ccb5..9a02a4a0ec00f 100644 --- a/ext/standard/tests/strings/strrpos_variation7.phpt +++ b/ext/standard/tests/strings/strrpos_variation7.phpt @@ -16,19 +16,21 @@ echo "-- With empty heredoc string --\n"; $empty_string = <<getMessage() . "\n"; +} var_dump( strrpos($empty_string, FALSE) ); var_dump( strrpos($empty_string, NULL) ); echo "*** Done ***"; ?> ---EXPECTF-- +--EXPECT-- *** Testing strrpos() function: with heredoc strings *** -- With empty heredoc string -- int(0) - -Warning: strrpos(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string int(0) int(0) *** Done *** diff --git a/ext/standard/tests/strings/substr_count_error.phpt b/ext/standard/tests/strings/substr_count_error.phpt index 246963d13b40e..9bdb3843ebce2 100644 --- a/ext/standard/tests/strings/substr_count_error.phpt +++ b/ext/standard/tests/strings/substr_count_error.phpt @@ -7,10 +7,18 @@ echo "\n*** Testing error conditions ***\n"; $str = 'abcdefghik'; /* offset before start */ -var_dump(substr_count($str, "t", -20)); +try { + substr_count($str, "t", -20); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} /* offset > size of the string */ -var_dump(substr_count($str, "t", 25)); +try { + substr_count($str, "t", 25); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} /* Using offset and length to go beyond the size of the string: Warning message expected, as length+offset > length of string */ @@ -24,12 +32,8 @@ echo "Done\n"; ?> --EXPECTF-- *** Testing error conditions *** - -Warning: substr_count(): Offset not contained in string in %s on line %d -bool(false) - -Warning: substr_count(): Offset not contained in string in %s on line %d -bool(false) +Offset not contained in string +Offset not contained in string Warning: substr_count(): Invalid length value in %s on line %d bool(false) From 49b87c0307f62aa9c202b819cf940363cb32f5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:36:04 +0100 Subject: [PATCH 18/21] Promote warnings to exceptions in *scanf() functions --- ext/standard/scanf.c | 6 +- ext/standard/tests/file/fscanf.phpt | 10 +- ext/standard/tests/file/fscanf_error.phpt | 22 ++- .../tests/file/fscanf_variation10.phpt | 14 +- .../tests/file/fscanf_variation11.phpt | 56 +++----- .../tests/file/fscanf_variation12.phpt | 80 ++++------- .../tests/file/fscanf_variation13.phpt | 24 ++-- .../tests/file/fscanf_variation14.phpt | 104 ++++---------- .../tests/file/fscanf_variation15.phpt | 68 +++------- .../tests/file/fscanf_variation16.phpt | 16 +-- .../tests/file/fscanf_variation17.phpt | 56 +++----- .../tests/file/fscanf_variation18.phpt | 80 ++++------- .../tests/file/fscanf_variation19.phpt | 24 ++-- .../tests/file/fscanf_variation2.phpt | 80 ++++------- .../tests/file/fscanf_variation20.phpt | 80 ++++------- .../tests/file/fscanf_variation21.phpt | 68 +++------- .../tests/file/fscanf_variation22.phpt | 16 +-- .../tests/file/fscanf_variation23.phpt | 56 +++----- .../tests/file/fscanf_variation24.phpt | 80 ++++------- .../tests/file/fscanf_variation25.phpt | 24 ++-- .../tests/file/fscanf_variation26.phpt | 28 ++-- .../tests/file/fscanf_variation27.phpt | 80 ++++------- .../tests/file/fscanf_variation28.phpt | 68 +++------- .../tests/file/fscanf_variation29.phpt | 16 +-- .../tests/file/fscanf_variation3.phpt | 68 +++------- .../tests/file/fscanf_variation30.phpt | 56 +++----- .../tests/file/fscanf_variation31.phpt | 80 ++++------- .../tests/file/fscanf_variation32.phpt | 24 ++-- .../tests/file/fscanf_variation33.phpt | 80 ++++------- .../tests/file/fscanf_variation34.phpt | 68 +++------- .../tests/file/fscanf_variation35.phpt | 16 +-- .../tests/file/fscanf_variation36.phpt | 56 +++----- .../tests/file/fscanf_variation37.phpt | 80 ++++------- .../tests/file/fscanf_variation38.phpt | 24 ++-- .../tests/file/fscanf_variation39.phpt | 80 ++++------- .../tests/file/fscanf_variation4.phpt | 16 +-- .../tests/file/fscanf_variation40.phpt | 68 +++------- .../tests/file/fscanf_variation41.phpt | 16 +-- .../tests/file/fscanf_variation42.phpt | 56 +++----- .../tests/file/fscanf_variation43.phpt | 80 ++++------- .../tests/file/fscanf_variation44.phpt | 24 ++-- .../tests/file/fscanf_variation45.phpt | 80 ++++------- .../tests/file/fscanf_variation46.phpt | 68 +++------- .../tests/file/fscanf_variation47.phpt | 16 +-- .../tests/file/fscanf_variation48.phpt | 56 +++----- .../tests/file/fscanf_variation49.phpt | 80 ++++------- .../tests/file/fscanf_variation5.phpt | 56 +++----- .../tests/file/fscanf_variation50.phpt | 24 ++-- .../tests/file/fscanf_variation6.phpt | 80 ++++------- .../tests/file/fscanf_variation7.phpt | 24 ++-- .../tests/file/fscanf_variation8.phpt | 128 +++++------------- .../tests/file/fscanf_variation9.phpt | 80 ++++------- 52 files changed, 889 insertions(+), 1851 deletions(-) diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index 687d063111568..e6bd88131673a 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -469,11 +469,11 @@ PHPAPI int ValidateFormat(char *format, int numVars, int *totalSubs) } break; badSet: - php_error_docref(NULL, E_WARNING, "Unmatched [ in format string"); + zend_value_error("Unmatched [ in format string"); goto error; default: { - php_error_docref(NULL, E_WARNING, "Bad scan conversion character \"%c\"", *ch); + zend_value_error("Bad scan conversion character \"%c\"", *ch); goto error; } } @@ -618,7 +618,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, if (numVars) { for (i = varStart;i < argCount;i++){ if ( ! Z_ISREF(args[ i ] ) ) { - php_error_docref(NULL, E_WARNING, "Parameter %d must be passed by reference", i); + zend_value_error("Parameter %d must be passed by reference", i); scan_set_error_return(numVars, return_value); return SCAN_ERROR_VAR_PASSED_BYVAL; } diff --git a/ext/standard/tests/file/fscanf.phpt b/ext/standard/tests/file/fscanf.phpt index 343138d002202..493a2d4cb8340 100644 --- a/ext/standard/tests/file/fscanf.phpt +++ b/ext/standard/tests/file/fscanf.phpt @@ -34,7 +34,11 @@ fclose($fp); $v = array(); $v1 = array(); $fp = fopen($filename, "rt"); -var_dump(fscanf($fp, "%.a", $v, $v1)); +try { + fscanf($fp, "%.a", $v, $v1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} var_dump($v); var_dump($v1); fclose($fp); @@ -76,9 +80,7 @@ array(0) { } array(0) { } - -Warning: fscanf(): Bad scan conversion character "." in %s on line %d -int(-1) +Bad scan conversion character "." array(0) { } array(0) { diff --git a/ext/standard/tests/file/fscanf_error.phpt b/ext/standard/tests/file/fscanf_error.phpt index 5666689574765..3cb2192be3ea6 100644 --- a/ext/standard/tests/file/fscanf_error.phpt +++ b/ext/standard/tests/file/fscanf_error.phpt @@ -42,7 +42,11 @@ foreach($invalid_formats as $format) { $file_handle = fopen($filename, 'r'); if ($file_handle == false) exit("Error:failed to open file $filename"); - var_dump( fscanf($file_handle, $format) ); + try { + var_dump( fscanf($file_handle, $format) ); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } fclose($file_handle); } @@ -64,17 +68,9 @@ int(-1) Warning: Undefined variable: undefined_var in %s on line %d array(0) { } - -Warning: fscanf(): Bad scan conversion character " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character "." in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character "m" in %s on line %d -NULL +Bad scan conversion character " +Bad scan conversion character " +Bad scan conversion character "." +Bad scan conversion character "m" *** Done *** diff --git a/ext/standard/tests/file/fscanf_variation10.phpt b/ext/standard/tests/file/fscanf_variation10.phpt index 158c6579d906d..9bdee4c724509 100644 --- a/ext/standard/tests/file/fscanf_variation10.phpt +++ b/ext/standard/tests/file/fscanf_variation10.phpt @@ -61,7 +61,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump( fscanf($file_handle,$float_format) ); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -148,12 +152,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation11.phpt b/ext/standard/tests/file/fscanf_variation11.phpt index 97dfa810a293e..8805a64ef984d 100644 --- a/ext/standard/tests/file/fscanf_variation11.phpt +++ b/ext/standard/tests/file/fscanf_variation11.phpt @@ -66,7 +66,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump(fscanf($file_handle,$float_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -79,7 +83,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation11.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different float format types with arrays *** -- iteration 1 -- @@ -389,42 +393,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation12.phpt b/ext/standard/tests/file/fscanf_variation12.phpt index a76e5b92a47af..3cfd942662541 100644 --- a/ext/standard/tests/file/fscanf_variation12.phpt +++ b/ext/standard/tests/file/fscanf_variation12.phpt @@ -67,7 +67,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump(fscanf($file_handle,$float_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation12.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different float format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation13.phpt b/ext/standard/tests/file/fscanf_variation13.phpt index 8f14e97e3229c..796831f32a0a7 100644 --- a/ext/standard/tests/file/fscanf_variation13.phpt +++ b/ext/standard/tests/file/fscanf_variation13.phpt @@ -53,7 +53,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump(fscanf($file_handle,$float_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -66,7 +70,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation13.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different float format types with boolean data *** -- iteration 1 -- @@ -148,18 +152,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation14.phpt b/ext/standard/tests/file/fscanf_variation14.phpt index 151c975776b92..557767978a757 100644 --- a/ext/standard/tests/file/fscanf_variation14.phpt +++ b/ext/standard/tests/file/fscanf_variation14.phpt @@ -99,7 +99,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -112,7 +116,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation14.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with different string *** -- iteration 1 -- @@ -566,78 +570,30 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation15.phpt b/ext/standard/tests/file/fscanf_variation15.phpt index f16b69789644d..d17776355744d 100644 --- a/ext/standard/tests/file/fscanf_variation15.phpt +++ b/ext/standard/tests/file/fscanf_variation15.phpt @@ -69,7 +69,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -82,7 +86,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation15.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with float values *** -- iteration 1 -- @@ -464,51 +468,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation16.phpt b/ext/standard/tests/file/fscanf_variation16.phpt index a9fd0cf84d1f4..80ed0d00c23c3 100644 --- a/ext/standard/tests/file/fscanf_variation16.phpt +++ b/ext/standard/tests/file/fscanf_variation16.phpt @@ -60,7 +60,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -77,7 +81,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation16.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with resource *** -- iteration 1 -- @@ -147,12 +151,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation17.phpt b/ext/standard/tests/file/fscanf_variation17.phpt index 4e976c7cb4ff1..8b7fd27967bfc 100644 --- a/ext/standard/tests/file/fscanf_variation17.phpt +++ b/ext/standard/tests/file/fscanf_variation17.phpt @@ -65,7 +65,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -78,7 +82,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation17.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with arrays *** -- iteration 1 -- @@ -388,42 +392,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation18.phpt b/ext/standard/tests/file/fscanf_variation18.phpt index 3887170b96f5f..af90fffadf642 100644 --- a/ext/standard/tests/file/fscanf_variation18.phpt +++ b/ext/standard/tests/file/fscanf_variation18.phpt @@ -73,7 +73,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -86,7 +90,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation18.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with integer values *** -- iteration 1 -- @@ -540,60 +544,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation19.phpt b/ext/standard/tests/file/fscanf_variation19.phpt index 5558c7786a588..bfb5d40223ab7 100644 --- a/ext/standard/tests/file/fscanf_variation19.phpt +++ b/ext/standard/tests/file/fscanf_variation19.phpt @@ -57,7 +57,11 @@ foreach($string_formats as $string_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$string_format) ); + try { + var_dump(fscanf($file_handle,$string_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -70,7 +74,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation19.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different string format types with boolean data *** -- iteration 1 -- @@ -152,18 +156,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation2.phpt b/ext/standard/tests/file/fscanf_variation2.phpt index 7ef77a675412c..50aba154a9302 100644 --- a/ext/standard/tests/file/fscanf_variation2.phpt +++ b/ext/standard/tests/file/fscanf_variation2.phpt @@ -67,7 +67,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump(fscanf($file_handle,$int_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation2.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with different integer values *** -- iteration 1 -- @@ -534,60 +538,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation20.phpt b/ext/standard/tests/file/fscanf_variation20.phpt index 2db263b79fb2e..10f3a2142d6df 100644 --- a/ext/standard/tests/file/fscanf_variation20.phpt +++ b/ext/standard/tests/file/fscanf_variation20.phpt @@ -71,7 +71,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -84,7 +88,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation20.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with different integer values *** -- iteration 1 -- @@ -538,60 +542,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation21.phpt b/ext/standard/tests/file/fscanf_variation21.phpt index 1275064d6a297..39958c8de8f1e 100644 --- a/ext/standard/tests/file/fscanf_variation21.phpt +++ b/ext/standard/tests/file/fscanf_variation21.phpt @@ -69,7 +69,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -82,7 +86,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation21.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with float values *** -- iteration 1 -- @@ -464,51 +468,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation22.phpt b/ext/standard/tests/file/fscanf_variation22.phpt index adb848a908544..168ef468bf17c 100644 --- a/ext/standard/tests/file/fscanf_variation22.phpt +++ b/ext/standard/tests/file/fscanf_variation22.phpt @@ -60,7 +60,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -77,7 +81,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation22.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with resource *** -- iteration 1 -- @@ -147,12 +151,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation23.phpt b/ext/standard/tests/file/fscanf_variation23.phpt index c1b9ca6580e9f..cdc5e138ab5fc 100644 --- a/ext/standard/tests/file/fscanf_variation23.phpt +++ b/ext/standard/tests/file/fscanf_variation23.phpt @@ -65,7 +65,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -78,7 +82,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation23.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with arrays *** -- iteration 1 -- @@ -388,42 +392,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation24.phpt b/ext/standard/tests/file/fscanf_variation24.phpt index eb7053587cac9..1177e2e2d0a45 100644 --- a/ext/standard/tests/file/fscanf_variation24.phpt +++ b/ext/standard/tests/file/fscanf_variation24.phpt @@ -71,7 +71,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -84,7 +88,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation24.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with strings *** -- iteration 1 -- @@ -532,60 +536,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation25.phpt b/ext/standard/tests/file/fscanf_variation25.phpt index 41d9bdc009b00..ba37a07a3ee25 100644 --- a/ext/standard/tests/file/fscanf_variation25.phpt +++ b/ext/standard/tests/file/fscanf_variation25.phpt @@ -57,7 +57,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -70,7 +74,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation25.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with boolean data *** -- iteration 1 -- @@ -182,18 +186,10 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation26.phpt b/ext/standard/tests/file/fscanf_variation26.phpt index d777e2ce8d5f7..bd499d37c5519 100644 --- a/ext/standard/tests/file/fscanf_variation26.phpt +++ b/ext/standard/tests/file/fscanf_variation26.phpt @@ -52,7 +52,11 @@ foreach($char_formats as $char_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$char_format) ); + try { + var_dump(fscanf($file_handle,$char_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -65,7 +69,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation26.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different char format types with chars *** -- iteration 1 -- @@ -207,21 +211,11 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation27.phpt b/ext/standard/tests/file/fscanf_variation27.phpt index 1d81190e9b138..ca27895eacd78 100644 --- a/ext/standard/tests/file/fscanf_variation27.phpt +++ b/ext/standard/tests/file/fscanf_variation27.phpt @@ -72,7 +72,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -85,7 +89,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation27.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with different integer values *** -- iteration 1 -- @@ -539,60 +543,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation28.phpt b/ext/standard/tests/file/fscanf_variation28.phpt index 4a791259bcfd4..93b476dd44585 100644 --- a/ext/standard/tests/file/fscanf_variation28.phpt +++ b/ext/standard/tests/file/fscanf_variation28.phpt @@ -70,7 +70,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -83,7 +87,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation28.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with float values *** -- iteration 1 -- @@ -465,51 +469,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation29.phpt b/ext/standard/tests/file/fscanf_variation29.phpt index 1db49732906b6..9e564e9cc44b6 100644 --- a/ext/standard/tests/file/fscanf_variation29.phpt +++ b/ext/standard/tests/file/fscanf_variation29.phpt @@ -61,7 +61,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -78,7 +82,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation29.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with resource *** -- iteration 1 -- @@ -148,12 +152,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation3.phpt b/ext/standard/tests/file/fscanf_variation3.phpt index 225fb6a0dec26..f52cca4181b89 100644 --- a/ext/standard/tests/file/fscanf_variation3.phpt +++ b/ext/standard/tests/file/fscanf_variation3.phpt @@ -71,7 +71,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump( fscanf($file_handle,$int_format) ); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -84,7 +88,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation3.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with float values *** -- iteration 1 -- @@ -466,51 +470,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation30.phpt b/ext/standard/tests/file/fscanf_variation30.phpt index c01f5aa2e6b0e..17ad8132f0ee4 100644 --- a/ext/standard/tests/file/fscanf_variation30.phpt +++ b/ext/standard/tests/file/fscanf_variation30.phpt @@ -66,7 +66,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -79,7 +83,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation30.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with arrays *** -- iteration 1 -- @@ -389,42 +393,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation31.phpt b/ext/standard/tests/file/fscanf_variation31.phpt index 2702fbc535379..cf1120644a4b4 100644 --- a/ext/standard/tests/file/fscanf_variation31.phpt +++ b/ext/standard/tests/file/fscanf_variation31.phpt @@ -67,7 +67,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation31.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation32.phpt b/ext/standard/tests/file/fscanf_variation32.phpt index 36f3f568813c4..ef0c2b70369a1 100644 --- a/ext/standard/tests/file/fscanf_variation32.phpt +++ b/ext/standard/tests/file/fscanf_variation32.phpt @@ -58,7 +58,11 @@ foreach($octal_formats as $octal_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$octal_format) ); + try { + var_dump(fscanf($file_handle,$octal_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -71,7 +75,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation32.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different octal format types with boolean data *** -- iteration 1 -- @@ -153,18 +157,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation33.phpt b/ext/standard/tests/file/fscanf_variation33.phpt index a444462a098c7..357544d1c46fb 100644 --- a/ext/standard/tests/file/fscanf_variation33.phpt +++ b/ext/standard/tests/file/fscanf_variation33.phpt @@ -78,7 +78,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -91,7 +95,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation33.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with different integer values *** -- iteration 1 -- @@ -545,60 +549,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation34.phpt b/ext/standard/tests/file/fscanf_variation34.phpt index a2d1ffdf01353..949ee5fb568b8 100644 --- a/ext/standard/tests/file/fscanf_variation34.phpt +++ b/ext/standard/tests/file/fscanf_variation34.phpt @@ -75,7 +75,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -88,7 +92,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation34.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with float values *** -- iteration 1 -- @@ -470,51 +474,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation35.phpt b/ext/standard/tests/file/fscanf_variation35.phpt index 445280c2fd530..b9a1edb7ce147 100644 --- a/ext/standard/tests/file/fscanf_variation35.phpt +++ b/ext/standard/tests/file/fscanf_variation35.phpt @@ -56,7 +56,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -73,7 +77,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation35.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with resource *** -- iteration 1 -- @@ -143,12 +147,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation36.phpt b/ext/standard/tests/file/fscanf_variation36.phpt index 9eb617077dfc9..fbef122c8f8d7 100644 --- a/ext/standard/tests/file/fscanf_variation36.phpt +++ b/ext/standard/tests/file/fscanf_variation36.phpt @@ -61,7 +61,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -74,7 +78,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation36.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with arrays *** -- iteration 1 -- @@ -384,42 +388,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation37.phpt b/ext/standard/tests/file/fscanf_variation37.phpt index 9acdfa489c7e6..c31768d8fed93 100644 --- a/ext/standard/tests/file/fscanf_variation37.phpt +++ b/ext/standard/tests/file/fscanf_variation37.phpt @@ -67,7 +67,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation37.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation38.phpt b/ext/standard/tests/file/fscanf_variation38.phpt index eabe5a05b439f..d42a9a8f78d2f 100644 --- a/ext/standard/tests/file/fscanf_variation38.phpt +++ b/ext/standard/tests/file/fscanf_variation38.phpt @@ -53,7 +53,11 @@ foreach($hexa_formats as $hexa_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$hexa_format) ); + try { + var_dump(fscanf($file_handle,$hexa_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -66,7 +70,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation38.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different hexa format types with boolean data *** -- iteration 1 -- @@ -148,18 +152,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation39.phpt b/ext/standard/tests/file/fscanf_variation39.phpt index 011a714e1c644..f92fccf3d177e 100644 --- a/ext/standard/tests/file/fscanf_variation39.phpt +++ b/ext/standard/tests/file/fscanf_variation39.phpt @@ -73,7 +73,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -86,7 +90,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation39.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned int format types with different integer values *** -- iteration 1 -- @@ -540,60 +544,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation4.phpt b/ext/standard/tests/file/fscanf_variation4.phpt index b802a90da3295..61eac42e38020 100644 --- a/ext/standard/tests/file/fscanf_variation4.phpt +++ b/ext/standard/tests/file/fscanf_variation4.phpt @@ -57,7 +57,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump(fscanf($file_handle,$int_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -74,7 +78,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation4.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with resource *** -- iteration 1 -- @@ -144,12 +148,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation40.phpt b/ext/standard/tests/file/fscanf_variation40.phpt index c65aaac9c7213..986d1face44fe 100644 --- a/ext/standard/tests/file/fscanf_variation40.phpt +++ b/ext/standard/tests/file/fscanf_variation40.phpt @@ -71,7 +71,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -84,7 +88,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation40.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned format types with float values *** -- iteration 1 -- @@ -466,51 +470,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation41.phpt b/ext/standard/tests/file/fscanf_variation41.phpt index 487954097f68c..d09f8d0bdf4a6 100644 --- a/ext/standard/tests/file/fscanf_variation41.phpt +++ b/ext/standard/tests/file/fscanf_variation41.phpt @@ -56,7 +56,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -73,7 +77,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation41.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned format types with resource *** -- iteration 1 -- @@ -143,12 +147,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation42.phpt b/ext/standard/tests/file/fscanf_variation42.phpt index 45cf3696b59e6..826869f14c21d 100644 --- a/ext/standard/tests/file/fscanf_variation42.phpt +++ b/ext/standard/tests/file/fscanf_variation42.phpt @@ -61,7 +61,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -74,7 +78,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation42.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned format types with arrays *** -- iteration 1 -- @@ -384,42 +388,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation43.phpt b/ext/standard/tests/file/fscanf_variation43.phpt index bc19326e621e4..399e9c72b7d5c 100644 --- a/ext/standard/tests/file/fscanf_variation43.phpt +++ b/ext/standard/tests/file/fscanf_variation43.phpt @@ -67,7 +67,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation43.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation44.phpt b/ext/standard/tests/file/fscanf_variation44.phpt index 6c61ba950779c..cdc9befcf2ca9 100644 --- a/ext/standard/tests/file/fscanf_variation44.phpt +++ b/ext/standard/tests/file/fscanf_variation44.phpt @@ -53,7 +53,11 @@ foreach($unsigned_formats as $unsigned_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$unsigned_format) ); + try { + var_dump(fscanf($file_handle,$unsigned_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -66,7 +70,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation44.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different unsigned format types with boolean data *** -- iteration 1 -- @@ -148,18 +152,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation45.phpt b/ext/standard/tests/file/fscanf_variation45.phpt index 87192cbb7c798..31a05d26fab6a 100644 --- a/ext/standard/tests/file/fscanf_variation45.phpt +++ b/ext/standard/tests/file/fscanf_variation45.phpt @@ -67,7 +67,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation45.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with different integer values *** -- iteration 1 -- @@ -534,60 +538,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation46.phpt b/ext/standard/tests/file/fscanf_variation46.phpt index 690918bdf1e39..5c2527f33b4b0 100644 --- a/ext/standard/tests/file/fscanf_variation46.phpt +++ b/ext/standard/tests/file/fscanf_variation46.phpt @@ -65,7 +65,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -78,7 +82,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation46.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with float values *** -- iteration 1 -- @@ -460,51 +464,21 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation47.phpt b/ext/standard/tests/file/fscanf_variation47.phpt index 6217b32b61a43..05f773d8a2c73 100644 --- a/ext/standard/tests/file/fscanf_variation47.phpt +++ b/ext/standard/tests/file/fscanf_variation47.phpt @@ -56,7 +56,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -73,7 +77,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation47.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with resource *** -- iteration 1 -- @@ -143,12 +147,8 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation48.phpt b/ext/standard/tests/file/fscanf_variation48.phpt index 355d5cf187722..0691f9405981d 100644 --- a/ext/standard/tests/file/fscanf_variation48.phpt +++ b/ext/standard/tests/file/fscanf_variation48.phpt @@ -61,7 +61,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -74,7 +78,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation48.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with arrays *** -- iteration 1 -- @@ -384,42 +388,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation49.phpt b/ext/standard/tests/file/fscanf_variation49.phpt index 5355db9a5aa8a..5ec5ab199d5f2 100644 --- a/ext/standard/tests/file/fscanf_variation49.phpt +++ b/ext/standard/tests/file/fscanf_variation49.phpt @@ -67,7 +67,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation49.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation5.phpt b/ext/standard/tests/file/fscanf_variation5.phpt index 714a54b912a00..9bdaec0585703 100644 --- a/ext/standard/tests/file/fscanf_variation5.phpt +++ b/ext/standard/tests/file/fscanf_variation5.phpt @@ -61,7 +61,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump(fscanf($file_handle,$int_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -74,7 +78,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation5.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with arrays *** -- iteration 1 -- @@ -384,42 +388,18 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation50.phpt b/ext/standard/tests/file/fscanf_variation50.phpt index 4853ba10ca3f6..6cb8e9fee644b 100644 --- a/ext/standard/tests/file/fscanf_variation50.phpt +++ b/ext/standard/tests/file/fscanf_variation50.phpt @@ -53,7 +53,11 @@ foreach($scientific_formats as $scientific_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$scientific_format) ); + try { + var_dump(fscanf($file_handle,$scientific_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -66,7 +70,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation50.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different scientific format types with boolean data *** -- iteration 1 -- @@ -148,18 +152,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation6.phpt b/ext/standard/tests/file/fscanf_variation6.phpt index f2038cd1c8b72..e4df9faafadb4 100644 --- a/ext/standard/tests/file/fscanf_variation6.phpt +++ b/ext/standard/tests/file/fscanf_variation6.phpt @@ -67,7 +67,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump(fscanf($file_handle,$int_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -80,7 +84,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation6.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with strings *** -- iteration 1 -- @@ -498,60 +502,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation7.phpt b/ext/standard/tests/file/fscanf_variation7.phpt index 5be243660735a..5978a150879bc 100644 --- a/ext/standard/tests/file/fscanf_variation7.phpt +++ b/ext/standard/tests/file/fscanf_variation7.phpt @@ -53,7 +53,11 @@ foreach($int_formats as $int_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$int_format) ); + try { + var_dump(fscanf($file_handle,$int_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -66,7 +70,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation7.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different integer format types with boolean data *** -- iteration 1 -- @@ -148,18 +152,10 @@ NULL bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation8.phpt b/ext/standard/tests/file/fscanf_variation8.phpt index cd7dd35fd947c..0f851ad21a11f 100644 --- a/ext/standard/tests/file/fscanf_variation8.phpt +++ b/ext/standard/tests/file/fscanf_variation8.phpt @@ -85,7 +85,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump(fscanf($file_handle,$float_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -98,7 +102,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation8.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different float format types with different float values *** -- iteration 1 -- @@ -840,96 +844,36 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- diff --git a/ext/standard/tests/file/fscanf_variation9.phpt b/ext/standard/tests/file/fscanf_variation9.phpt index 40470db064643..7abcb6fc6455d 100644 --- a/ext/standard/tests/file/fscanf_variation9.phpt +++ b/ext/standard/tests/file/fscanf_variation9.phpt @@ -74,7 +74,11 @@ foreach($float_formats as $float_format) { rewind($file_handle); echo "\n-- iteration $counter --\n"; while( !feof($file_handle) ) { - var_dump( fscanf($file_handle,$float_format) ); + try { + var_dump(fscanf($file_handle,$float_format)); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } $counter++; } @@ -87,7 +91,7 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_variation9.tmp"; unlink($filename); ?> ---EXPECTF-- +--EXPECT-- *** Test fscanf(): different float format types with integer values *** -- iteration 1 -- @@ -541,60 +545,24 @@ array(1) { bool(false) -- iteration 7 -- - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL - -Warning: fscanf(): Bad scan conversion character " " in %s on line %d -NULL +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " +Bad scan conversion character " " bool(false) -- iteration 8 -- From 5025c8891e801ddca6b76d72041a2a54c2df2e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 02:37:11 +0100 Subject: [PATCH 19/21] Promote warning to exception in the convert_uudecode() function --- ext/standard/tests/strings/bug67252.phpt | 14 +++++++------- ext/standard/uuencode.c | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ext/standard/tests/strings/bug67252.phpt b/ext/standard/tests/strings/bug67252.phpt index eab2112afa359..8f0bba51fba8d 100644 --- a/ext/standard/tests/strings/bug67252.phpt +++ b/ext/standard/tests/strings/bug67252.phpt @@ -2,11 +2,11 @@ Bug #67252 (convert_uudecode out-of-bounds read) --FILE-- getMessage() . "\n"; +} ?> ---EXPECTF-- -Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d -bool(false) +--EXPECT-- +The given parameter is not a valid uuencoded string diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c index 036e190f24277..2134821f8b6cc 100644 --- a/ext/standard/uuencode.c +++ b/ext/standard/uuencode.c @@ -222,8 +222,8 @@ PHP_FUNCTION(convert_uudecode) if (ZSTR_LEN(src) < 1) { RETURN_FALSE; } if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) { - php_error_docref(NULL, E_WARNING, "The given parameter is not a valid uuencoded string"); - RETURN_FALSE; + zend_value_error("The given parameter is not a valid uuencoded string"); + return; } RETURN_STR(dest); From 023f629bcd38571fd7dd8d5178f9aa1458bb06b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 14:17:26 +0100 Subject: [PATCH 20/21] Promote warnings to exceptions in register_shutdown_handler() function --- Zend/tests/bug41026.phpt | 10 ++++++---- ext/standard/basic_functions.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Zend/tests/bug41026.phpt b/Zend/tests/bug41026.phpt index e159ad36f6db4..0843d37d13df4 100644 --- a/Zend/tests/bug41026.phpt +++ b/Zend/tests/bug41026.phpt @@ -7,7 +7,7 @@ class try_class { static public function main () { - register_shutdown_function (array ("self", "on_shutdown")); + register_shutdown_function(array ("self", "on_shutdown")); } static public function on_shutdown () @@ -16,11 +16,13 @@ class try_class } } -try_class::main (); - +try_class::main(); echo "Done\n"; ?> --EXPECT-- Done -Warning: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in Unknown on line 0 +Fatal error: Uncaught ValueError: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in [no active file]:0 +Stack trace: +#0 {main} + thrown in [no active file] on line 0 diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 767813a9b6d04..73e12af6cd4fa 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3202,7 +3202,7 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */ if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, NULL)) { zend_string *function_name = zend_get_callable_name(&shutdown_function_entry->arguments[0]); - php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); + zend_value_error("(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); zend_string_release_ex(function_name, 0); return 0; } From ddd8362116120f8919ac29dad8cbb41f4ac73009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 20 Nov 2019 14:22:53 +0100 Subject: [PATCH 21/21] Promote warnings to exceptions in register_tick_function() function --- ext/standard/basic_functions.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 73e12af6cd4fa..4f0573624639c 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3240,15 +3240,15 @@ static void user_tick_function_call(user_tick_function_entry *tick_fe) /* {{{ */ zval *obj, *method; if (Z_TYPE_P(function) == IS_STRING) { - php_error_docref(NULL, E_WARNING, "Unable to call %s() - function does not exist", Z_STRVAL_P(function)); + zend_value_error("Unable to call %s() - function does not exist", Z_STRVAL_P(function)); } else if ( Z_TYPE_P(function) == IS_ARRAY && (obj = zend_hash_index_find(Z_ARRVAL_P(function), 0)) != NULL && (method = zend_hash_index_find(Z_ARRVAL_P(function), 1)) != NULL && Z_TYPE_P(obj) == IS_OBJECT && Z_TYPE_P(method) == IS_STRING) { - php_error_docref(NULL, E_WARNING, "Unable to call %s::%s() - function does not exist", ZSTR_VAL(Z_OBJCE_P(obj)->name), Z_STRVAL_P(method)); + zend_value_error("Unable to call %s::%s() - function does not exist", ZSTR_VAL(Z_OBJCE_P(obj)->name), Z_STRVAL_P(method)); } else { - php_error_docref(NULL, E_WARNING, "Unable to call tick function"); + zend_value_error("Unable to call tick function"); } }