Skip to content

Commit f2b6b7f

Browse files
authored
ext/gmp: Fix GMP error messages using outdated parameter names (#22846)
The argument name in these error messages are different from what is claimed in the documentation and public signatures. Updated messages: - gmp_root() and gmp_rootrem() now refer to argument 1 as $num instead of $a. - gmp_random_range() now refers to argument 2 as $max instead of $maximum.
1 parent f6fe838 commit f2b6b7f

5 files changed

Lines changed: 10 additions & 8 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PHP NEWS
1616
the unsigned long range instead of silently truncating them. (Weilin Du)
1717
. Fixed GMP integer string parsing to reject strings containing NUL bytes
1818
instead of silently truncating them. (Weilin Du)
19+
. Fixed GMP error messages that referenced outdated parameter names.
20+
(Weilin Du)
1921

2022
- Intl:
2123
. Fixed grammatical issues in Normalizer invalid form and IntlCalendar time

ext/gmp/gmp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ ZEND_FUNCTION(gmp_root)
12491249
}
12501250

12511251
if (nth % 2 == 0 && mpz_sgn(gmpnum_a) < 0) {
1252-
zend_argument_value_error(2, "must be odd if argument #1 ($a) is negative");
1252+
zend_argument_value_error(2, "must be odd if argument #1 ($num) is negative");
12531253
RETURN_THROWS();
12541254
}
12551255

@@ -1276,7 +1276,7 @@ ZEND_FUNCTION(gmp_rootrem)
12761276
}
12771277

12781278
if (nth % 2 == 0 && mpz_sgn(gmpnum_a) < 0) {
1279-
zend_argument_value_error(2, "must be odd if argument #1 ($a) is negative");
1279+
zend_argument_value_error(2, "must be odd if argument #1 ($num) is negative");
12801280
RETURN_THROWS();
12811281
}
12821282

@@ -1528,7 +1528,7 @@ ZEND_FUNCTION(gmp_random_range)
15281528

15291529
gmp_init_random();
15301530
if (mpz_cmp(gmpnum_max, gmpnum_min) <= 0) {
1531-
zend_argument_value_error(1, "must be less than argument #2 ($maximum)");
1531+
zend_argument_value_error(1, "must be less than argument #2 ($max)");
15321532
RETURN_THROWS();
15331533
}
15341534

ext/gmp/tests/gmp_random_range.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ while (1) {
7474
echo "Done\n";
7575
?>
7676
--EXPECT--
77-
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
78-
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
79-
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
77+
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
78+
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
79+
gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
8080
Done

ext/gmp/tests/gmp_remroot.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ array(2) {
9292
string(2) "19"
9393
}
9494
}
95-
gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($a) is negative
95+
gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
9696
array(2) {
9797
[0]=>
9898
object(GMP)#%d (1) {

ext/gmp/tests/gmp_root.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object(GMP)#%d (1) {
5353
["num"]=>
5454
string(1) "3"
5555
}
56-
gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($a) is negative
56+
gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
5757
object(GMP)#%d (1) {
5858
["num"]=>
5959
string(1) "0"

0 commit comments

Comments
 (0)