[php-src] master: Remove assert_options() return value info

From: Date: Wed, 28 Apr 2021 09:07:35 +0000
Subject: [php-src] master: Remove assert_options() return value info
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-115920@lists.php.net to get a copy of this message
Author: Nikita Popov (nikic) Date: 2021-04-28T11:05:05+02:00 Commit: https://github.com/php/php-src/commit/76d1120a489381d227374b85df30f77a3d1c5afb Raw diff: https://github.com/php/php-src/commit/76d1120a489381d227374b85df30f77a3d1c5afb.diff Remove assert_options() return value info The ASSERT_CALLBACK value is not validated at all -- it's possible to set it to an arbitrary value. As such, the function can also return any value or type (even without outright abuse, the opcache func info was wrong in that the return can be rcn, and the array can be array_of_ref). Changed paths: M ext/opcache/Optimizer/zend_func_info.c M ext/standard/basic_functions.stub.php M ext/standard/basic_functions_arginfo.h M ext/standard/tests/assert/assert_variation.phpt Diff: diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 0cedd6b07b619..1e71fbd1e6ebe 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -405,7 +405,6 @@ static const func_info_t func_infos[] = { F1("array_chunk", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY), F1("array_combine", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY), F1("pos", UNKNOWN_INFO), - F1("assert_options", MAY_BE_NULL | MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_OBJECT | MAY_BE_OBJECT), F1("str_rot13", MAY_BE_STRING), F1("stream_get_filters", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING), F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT), diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 94b7b4da48317..72d28600e70ee 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -528,7 +528,7 @@ function get_html_translation_table(int $table = HTML_SPECIALCHARS, int $flags = function assert(mixed $assertion, Throwable|string|null $description = null): bool {} -function assert_options(int $option, mixed $value = UNKNOWN): array|object|int|string|null {} +function assert_options(int $option, mixed $value = UNKNOWN): mixed {} /* string.c */ diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 9aad2efb61598..4f9c36e44bdac 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b1d68b2f2dcc7a078257c65569f2eec284dcd804 */ + * Stub hash: 5063533a0887ff6045780b5521ee212de7e6be28 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -794,7 +794,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_assert, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_TYPE_MASK(0, description, Throwable, MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_assert_options, 0, 1, MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_LONG|MAY_BE_STRING|MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_assert_options, 0, 1, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/assert/assert_variation.phpt b/ext/standard/tests/assert/assert_variation.phpt index ff3d4a1e4dcef..1ed3dad230f96 100644 --- a/ext/standard/tests/assert/assert_variation.phpt +++ b/ext/standard/tests/assert/assert_variation.phpt @@ -68,6 +68,11 @@ var_dump($rao=assert_options(ASSERT_CALLBACK)); echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n\n"; var_dump($r2=assert(0 != 0)); echo"\n"; + +echo "Set callback to something silly\n"; +assert_options(ASSERT_CALLBACK, 3.141); +var_dump($rao = assert_options(ASSERT_CALLBACK)); + ?> --EXPECT-- Initial values: assert_options(ASSERT_CALLBACK) => [f1] @@ -126,3 +131,6 @@ ini.get("assert.callback") => [f2] Class assertion failed 60, "assert(0 != 0)" bool(false) + +Set callback to something silly +float(3.141)

« previous php.cvs (#115920) next »