forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elevate warnings to Error Exceptions in ext/bcmath
`bcdiv()` and `bcmod()` throw DivisionByZeroError if the divisor is 0, which matches the behavior of the `/` and `%` operators, and `bcsqrt()` throws ValueError for negative operands.
- Loading branch information
Showing
6 changed files
with
30 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ [email protected] | |
<?php if(!extension_loaded("bcmath")) print "skip"; ?> | ||
--FILE-- | ||
<?php | ||
echo bcdiv('10.99', '0'); | ||
try { | ||
bcdiv('10.99', '0'); | ||
} catch (DivisionByZeroError $ex) { | ||
echo $ex->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
--EXPECTF-- | ||
Warning: bcdiv(): Division by zero in %s.php on line %d | ||
--EXPECT-- | ||
Division by zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,11 @@ [email protected] | |
<?php if(!extension_loaded("bcmath")) print "skip"; ?> | ||
--FILE-- | ||
<?php | ||
echo bcsqrt('-9'); | ||
try { | ||
bcsqrt('-9'); | ||
} catch (ValueError $ex) { | ||
echo $ex->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
--EXPECTF-- | ||
Warning: bcsqrt(): Square root of negative number in %s.php on line %d | ||
--EXPECT-- | ||
Square root of negative number |