Skip to content

Commit 76d1120

Browse files
committed
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).
1 parent af9fadc commit 76d1120

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ static const func_info_t func_infos[] = {
405405
F1("array_chunk", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
406406
F1("array_combine", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
407407
F1("pos", UNKNOWN_INFO),
408-
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),
409408
F1("str_rot13", MAY_BE_STRING),
410409
F1("stream_get_filters", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
411410
F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT),

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ function get_html_translation_table(int $table = HTML_SPECIALCHARS, int $flags =
528528

529529
function assert(mixed $assertion, Throwable|string|null $description = null): bool {}
530530

531-
function assert_options(int $option, mixed $value = UNKNOWN): array|object|int|string|null {}
531+
function assert_options(int $option, mixed $value = UNKNOWN): mixed {}
532532

533533
/* string.c */
534534

ext/standard/basic_functions_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b1d68b2f2dcc7a078257c65569f2eec284dcd804 */
2+
* Stub hash: 5063533a0887ff6045780b5521ee212de7e6be28 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
55
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)
794794
ZEND_ARG_OBJ_TYPE_MASK(0, description, Throwable, MAY_BE_STRING|MAY_BE_NULL, "null")
795795
ZEND_END_ARG_INFO()
796796

797-
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)
797+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_assert_options, 0, 1, IS_MIXED, 0)
798798
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
799799
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
800800
ZEND_END_ARG_INFO()

ext/standard/tests/assert/assert_variation.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ var_dump($rao=assert_options(ASSERT_CALLBACK));
6868
echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n\n";
6969
var_dump($r2=assert(0 != 0));
7070
echo"\n";
71+
72+
echo "Set callback to something silly\n";
73+
assert_options(ASSERT_CALLBACK, 3.141);
74+
var_dump($rao = assert_options(ASSERT_CALLBACK));
75+
7176
?>
7277
--EXPECT--
7378
Initial values: assert_options(ASSERT_CALLBACK) => [f1]
@@ -126,3 +131,6 @@ ini.get("assert.callback") => [f2]
126131

127132
Class assertion failed 60, "assert(0 != 0)"
128133
bool(false)
134+
135+
Set callback to something silly
136+
float(3.141)

0 commit comments

Comments
 (0)