[php-src] master: ext/gmp: Fix GMP error messages using outdated parameter names (#22846)

Weilin Du via GitHub <[email protected]> Tue, 21 Jul 2026 11:39:09 +0000
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-07-21T19:39:06+08:00

Commit: https://github.com/php/php-src/commit/f2b6b7fd3c705e78cafda27e014a2c903ece5eb2
Raw diff: https://github.com/php/php-src/commit/f2b6b7fd3c705e78cafda27e014a2c903ece5eb2.diff

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.

Changed paths:
  M  NEWS
  M  ext/gmp/gmp.c
  M  ext/gmp/tests/gmp_random_range.phpt
  M  ext/gmp/tests/gmp_remroot.phpt
  M  ext/gmp/tests/gmp_root.phpt


Diff:

diff --git a/NEWS b/NEWS
index fd5b2d859ee0..217d6b959c81 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP                                                                        NEWS
     the unsigned long range instead of silently truncating them. (Weilin Du)
   . Fixed GMP integer string parsing to reject strings containing NUL bytes
     instead of silently truncating them. (Weilin Du)
+  . Fixed GMP error messages that referenced outdated parameter names.
+    (Weilin Du)
 
 - Intl:
   . Fixed grammatical issues in Normalizer invalid form and IntlCalendar time
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index a5cbdba3484e..7f8799a7ae2d 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -1249,7 +1249,7 @@ ZEND_FUNCTION(gmp_root)
 	}
 
 	if (nth % 2 == 0 && mpz_sgn(gmpnum_a) < 0) {
-		zend_argument_value_error(2, "must be odd if argument #1 ($a) is negative");
+		zend_argument_value_error(2, "must be odd if argument #1 ($num) is negative");
 		RETURN_THROWS();
 	}
 
@@ -1276,7 +1276,7 @@ ZEND_FUNCTION(gmp_rootrem)
 	}
 
 	if (nth % 2 == 0 && mpz_sgn(gmpnum_a) < 0) {
-		zend_argument_value_error(2, "must be odd if argument #1 ($a) is negative");
+		zend_argument_value_error(2, "must be odd if argument #1 ($num) is negative");
 		RETURN_THROWS();
 	}
 
@@ -1528,7 +1528,7 @@ ZEND_FUNCTION(gmp_random_range)
 
 	gmp_init_random();
 	if (mpz_cmp(gmpnum_max, gmpnum_min) <= 0) {
-		zend_argument_value_error(1, "must be less than argument #2 ($maximum)");
+		zend_argument_value_error(1, "must be less than argument #2 ($max)");
 		RETURN_THROWS();
 	}
 
diff --git a/ext/gmp/tests/gmp_random_range.phpt b/ext/gmp/tests/gmp_random_range.phpt
index ae87dbd82b18..59ac5762fce0 100644
--- a/ext/gmp/tests/gmp_random_range.phpt
+++ b/ext/gmp/tests/gmp_random_range.phpt
@@ -74,7 +74,7 @@ while (1) {
 echo "Done\n";
 ?>
 --EXPECT--
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
-gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($maximum)
+gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
+gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
+gmp_random_range(): Argument #1 ($min) must be less than argument #2 ($max)
 Done
diff --git a/ext/gmp/tests/gmp_remroot.phpt b/ext/gmp/tests/gmp_remroot.phpt
index de54d0e91c3e..fe7a8316e596 100644
--- a/ext/gmp/tests/gmp_remroot.phpt
+++ b/ext/gmp/tests/gmp_remroot.phpt
@@ -92,7 +92,7 @@ array(2) {
     string(2) "19"
   }
 }
-gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($a) is negative
+gmp_rootrem(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
 array(2) {
   [0]=>
   object(GMP)#%d (1) {
diff --git a/ext/gmp/tests/gmp_root.phpt b/ext/gmp/tests/gmp_root.phpt
index 36793e249721..b4a88405a211 100644
--- a/ext/gmp/tests/gmp_root.phpt
+++ b/ext/gmp/tests/gmp_root.phpt
@@ -53,7 +53,7 @@ object(GMP)#%d (1) {
   ["num"]=>
   string(1) "3"
 }
-gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($a) is negative
+gmp_root(): Argument #2 ($nth) must be odd if argument #1 ($num) is negative
 object(GMP)#%d (1) {
   ["num"]=>
   string(1) "0"