Skip to content

Commit 2d05775

Browse files
committed
Deprecate calling stream_context_set_option() with 2 arguments
1 parent b36eac9 commit 2d05775

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ PHP 8.4 UPGRADE NOTES
177177
. Calling session_set_save_handler() with more than 2 arguments is
178178
deprecated. Use the 2-parameter signature instead.
179179

180+
- Standard:
181+
. Calling stream_context_set_option() with 2 arguments is deprecated.
182+
Use stream_context_set_options() instead.
183+
180184
========================================
181185
5. Changed Functions
182186
========================================

ext/standard/streamsfuncs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,15 @@ PHP_FUNCTION(stream_context_set_option)
10211021
size_t optionname_len;
10221022
zval *zvalue = NULL;
10231023

1024+
if (ZEND_NUM_ARGS() == 2) {
1025+
zend_error(E_DEPRECATED, "Calling stream_context_set_option() with 2 arguments is deprecated, "
1026+
"use stream_context_set_options() instead"
1027+
);
1028+
if (UNEXPECTED(EG(exception))) {
1029+
RETURN_THROWS();
1030+
}
1031+
}
1032+
10241033
ZEND_PARSE_PARAMETERS_START(2, 4)
10251034
Z_PARAM_RESOURCE(zcontext)
10261035
Z_PARAM_ARRAY_HT_OR_STR(options, wrappername)

ext/standard/tests/streams/stream_context_set_option_basic.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ var_dump(stream_context_set_option($context, $options));
2121

2222
var_dump(stream_context_get_options($context));
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
2525
bool(true)
26+
27+
Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in %s on line %d
2628
bool(true)
2729
array(1) {
2830
["http"]=>

ext/standard/tests/streams/stream_context_set_option_error.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ try {
2626
}
2727

2828
?>
29-
--EXPECT--
29+
--EXPECTF--
3030
stream_context_set_option(): Argument #3 ($option_name) must be null when argument #2 ($wrapper_or_options) is an array
3131
stream_context_set_option(): Argument #4 ($value) cannot be provided when argument #2 ($wrapper_or_options) is an array
32+
33+
Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in %s on line %d
3234
stream_context_set_option(): Argument #3 ($option_name) cannot be null when argument #2 ($wrapper_or_options) is a string
3335
stream_context_set_option(): Argument #4 ($value) must be provided when argument #2 ($wrapper_or_options) is a string

0 commit comments

Comments
 (0)