diff --git a/UPGRADING b/UPGRADING index fee935d01cd..b35439e0c2e 100644 --- a/UPGRADING +++ b/UPGRADING @@ -177,6 +177,10 @@ PHP 8.4 UPGRADE NOTES . Calling session_set_save_handler() with more than 2 arguments is deprecated. Use the 2-parameter signature instead. +- Standard: + . Calling stream_context_set_option() with 2 arguments is deprecated. + Use stream_context_set_options() instead. + ======================================== 5. Changed Functions ======================================== diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 3140efa16e1..e8711f58920 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1021,6 +1021,15 @@ PHP_FUNCTION(stream_context_set_option) size_t optionname_len; zval *zvalue = NULL; + if (ZEND_NUM_ARGS() == 2) { + zend_error(E_DEPRECATED, "Calling stream_context_set_option() with 2 arguments is deprecated, " + "use stream_context_set_options() instead" + ); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } + } + ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_RESOURCE(zcontext) Z_PARAM_ARRAY_HT_OR_STR(options, wrappername) diff --git a/ext/standard/tests/streams/stream_context_set_option_basic.phpt b/ext/standard/tests/streams/stream_context_set_option_basic.phpt index 63730ee996b..aacb30a0813 100644 --- a/ext/standard/tests/streams/stream_context_set_option_basic.phpt +++ b/ext/standard/tests/streams/stream_context_set_option_basic.phpt @@ -21,8 +21,10 @@ var_dump(stream_context_set_option($context, $options)); var_dump(stream_context_get_options($context)); ?> ---EXPECT-- +--EXPECTF-- bool(true) + +Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in %s on line %d bool(true) array(1) { ["http"]=> diff --git a/ext/standard/tests/streams/stream_context_set_option_error.phpt b/ext/standard/tests/streams/stream_context_set_option_error.phpt index aaa09b7ace8..e52bb882f66 100644 --- a/ext/standard/tests/streams/stream_context_set_option_error.phpt +++ b/ext/standard/tests/streams/stream_context_set_option_error.phpt @@ -26,8 +26,10 @@ try { } ?> ---EXPECT-- +--EXPECTF-- stream_context_set_option(): Argument #3 ($option_name) must be null when argument #2 ($wrapper_or_options) is an array stream_context_set_option(): Argument #4 ($value) cannot be provided when argument #2 ($wrapper_or_options) is an array + +Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in %s on line %d stream_context_set_option(): Argument #3 ($option_name) cannot be null when argument #2 ($wrapper_or_options) is a string stream_context_set_option(): Argument #4 ($value) must be provided when argument #2 ($wrapper_or_options) is a string