Skip to content

Commit 9efd9cc

Browse files
committed
fixup! Promote warnings to exceptions in stream-related functions
Fix exception types
1 parent 9907946 commit 9efd9cc

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

ext/standard/streamsfuncs.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ static int parse_context_params(php_stream_context *context, zval *params)
921921
if (Z_TYPE_P(tmp) == IS_ARRAY) {
922922
return parse_context_options(context, tmp);
923923
} else {
924-
zend_value_error("Invalid stream/context parameter");
924+
zend_type_error("Invalid stream/context parameter");
925925
return FAILURE;
926926
}
927927
}
@@ -972,7 +972,7 @@ PHP_FUNCTION(stream_context_get_options)
972972

973973
context = decode_context_param(zcontext);
974974
if (!context) {
975-
zend_value_error("Invalid stream/context parameter");
975+
zend_type_error("Invalid stream/context parameter");
976976
return;
977977
}
978978

@@ -997,7 +997,7 @@ PHP_FUNCTION(stream_context_set_option)
997997

998998
/* figure out where the context is coming from exactly */
999999
if (!(context = decode_context_param(zcontext))) {
1000-
zend_value_error("Invalid stream/context parameter");
1000+
zend_type_error("Invalid stream/context parameter");
10011001
return;
10021002
}
10031003

@@ -1016,7 +1016,7 @@ PHP_FUNCTION(stream_context_set_option)
10161016

10171017
/* figure out where the context is coming from exactly */
10181018
if (!(context = decode_context_param(zcontext))) {
1019-
zend_value_error("Invalid stream/context parameter");
1019+
zend_type_error("Invalid stream/context parameter");
10201020
return;
10211021
}
10221022

@@ -1039,7 +1039,7 @@ PHP_FUNCTION(stream_context_set_params)
10391039

10401040
context = decode_context_param(zcontext);
10411041
if (!context) {
1042-
zend_value_error("Invalid stream/context parameter");
1042+
zend_type_error("Invalid stream/context parameter");
10431043
return;
10441044
}
10451045

@@ -1060,7 +1060,7 @@ PHP_FUNCTION(stream_context_get_params)
10601060

10611061
context = decode_context_param(zcontext);
10621062
if (!context) {
1063-
zend_value_error("Invalid stream/context parameter");
1063+
zend_type_error("Invalid stream/context parameter");
10641064
return;
10651065
}
10661066

@@ -1259,9 +1259,8 @@ PHP_FUNCTION(stream_filter_remove)
12591259
Z_PARAM_RESOURCE(zfilter)
12601260
ZEND_PARSE_PARAMETERS_END();
12611261

1262-
filter = zend_fetch_resource(Z_RES_P(zfilter), NULL, php_file_le_stream_filter());
1262+
filter = zend_fetch_resource(Z_RES_P(zfilter), "stream filter", php_file_le_stream_filter());
12631263
if (!filter) {
1264-
zend_value_error("Invalid resource given, not a stream filter");
12651264
return;
12661265
}
12671266

@@ -1435,7 +1434,7 @@ PHP_FUNCTION(stream_set_chunk_size)
14351434
ZEND_PARSE_PARAMETERS_END();
14361435

14371436
if (csize <= 0) {
1438-
zend_value_error("The chunk size must be a positive integer, given " ZEND_LONG_FMT, csize);
1437+
zend_value_error("The chunk size must be a positive integer, " ZEND_LONG_FMT " given", csize);
14391438
return;
14401439
}
14411440
/* stream.chunk_size is actually a size_t, but php_stream_set_option

ext/standard/tests/filters/stream_filter_remove_error.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ echo "*** Testing stream_filter_remove() : error conditions ***\n";
2323
echo "\n-- Testing stream_filter_remove() function with bad resource --\n";
2424
try {
2525
stream_filter_remove($fp);
26-
} catch (ValueError $exception) {
26+
} catch (TypeError $exception) {
2727
echo $exception->getMessage() . "\n";
2828
}
2929

@@ -32,7 +32,7 @@ echo "\n-- Testing stream_filter_remove() function with an already removed filte
3232
var_dump(stream_filter_remove( $filter ));
3333
try {
3434
stream_filter_remove($filter);
35-
} catch (ValueError $exception) {
35+
} catch (TypeError $exception) {
3636
echo $exception->getMessage() . "\n";
3737
}
3838

@@ -50,8 +50,8 @@ unlink( $file );
5050
*** Testing stream_filter_remove() : error conditions ***
5151

5252
-- Testing stream_filter_remove() function with bad resource --
53-
Invalid resource given, not a stream filter
53+
stream_filter_remove(): supplied resource is not a valid stream filter resource
5454

5555
-- Testing stream_filter_remove() function with an already removed filter --
5656
bool(true)
57-
Invalid resource given, not a stream filter
57+
stream_filter_remove(): supplied resource is not a valid stream filter resource

ext/standard/tests/streams/bug44712.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bug#44712 (stream_context_set_params segfaults on invalid arguments)
55
$ctx = stream_context_get_default();
66
try {
77
stream_context_set_params($ctx, array("options" => 1));
8-
} catch (ValueError $exception) {
8+
} catch (TypeError $exception) {
99
echo $exception->getMessage() . "\n";
1010
}
1111
?>

ext/standard/tests/streams/stream_set_chunk_size.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ write with size: 250
8484
int(3)
8585

8686
error conditions
87-
The chunk size must be a positive integer, given 0
88-
The chunk size must be a positive integer, given -1
87+
The chunk size must be a positive integer, 0 given
88+
The chunk size must be a positive integer, -1 given

0 commit comments

Comments
 (0)