File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,17 @@ PHP_FUNCTION(round)
335
335
}
336
336
}
337
337
338
+ switch (mode ) {
339
+ case PHP_ROUND_HALF_UP :
340
+ case PHP_ROUND_HALF_DOWN :
341
+ case PHP_ROUND_HALF_EVEN :
342
+ case PHP_ROUND_HALF_ODD :
343
+ break ;
344
+ default :
345
+ zend_argument_value_error (3 , "must be a valid rounding mode (PHP_ROUND_*)" );
346
+ RETURN_THROWS ();
347
+ }
348
+
338
349
switch (Z_TYPE_P (value )) {
339
350
case IS_LONG :
340
351
/* Simple case - long that doesn't need to be rounded. */
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ round() rejects invalid rounding modes.
3
+ --FILE--
4
+ <?php
5
+ var_dump (round (1.5 , mode: 1234 ));
6
+ ?>
7
+ --EXPECTF--
8
+ Fatal error: Uncaught ValueError: round(): Argument #3 ($mode) must be a valid rounding mode (PHP_ROUND_*) in %s:%d
9
+ Stack trace:
10
+ #0 %s(%d): round(1.5, 0, 1234)
11
+ #1 {main}
12
+ thrown in %s on line %d
You can’t perform that action at this time.
0 commit comments