From 4dc4d319fbb9941aba4479418fed03f427432d2a Mon Sep 17 00:00:00 2001
From: qodelicious <162776175+qodelicious@users.noreply.github.com>
Date: Thu, 22 Oct 2026 11:26:25 +0000
Subject: [PATCH 1/4] gmp: document the ValueErrors for negative and out of
range arguments
---
reference/gmp/functions/gmp-clrbit.xml | 10 ++++++++++
reference/gmp/functions/gmp-fact.xml | 10 ++++++++++
reference/gmp/functions/gmp-pow.xml | 12 ++++++++++--
reference/gmp/functions/gmp-powm.xml | 14 ++++++++++++++
reference/gmp/functions/gmp-root.xml | 11 +++++++++++
reference/gmp/functions/gmp-rootrem.xml | 11 +++++++++++
reference/gmp/functions/gmp-scan0.xml | 10 ++++++++++
reference/gmp/functions/gmp-scan1.xml | 10 ++++++++++
reference/gmp/functions/gmp-setbit.xml | 10 ++++++++++
reference/gmp/functions/gmp-sqrt.xml | 10 ++++++++++
reference/gmp/functions/gmp-sqrtrem.xml | 10 ++++++++++
reference/gmp/functions/gmp-strval.xml | 11 +++++++++++
reference/gmp/functions/gmp-testbit.xml | 11 ++++++-----
13 files changed, 133 insertions(+), 7 deletions(-)
diff --git a/reference/gmp/functions/gmp-clrbit.xml b/reference/gmp/functions/gmp-clrbit.xml
index fd6f56899b9c..3d9e959097ee 100644
--- a/reference/gmp/functions/gmp-clrbit.xml
+++ b/reference/gmp/functions/gmp-clrbit.xml
@@ -50,6 +50,16 @@
+
+ &reftitle.errors;
+
+ Throws a ValueError if index is negative or too large.
+
+
+ Prior to PHP 8.0.0, an E_WARNING was raised instead.
+
+
+
&reftitle.examples;
diff --git a/reference/gmp/functions/gmp-fact.xml b/reference/gmp/functions/gmp-fact.xml
index dc58908b1dcb..178f86ba306b 100644
--- a/reference/gmp/functions/gmp-fact.xml
+++ b/reference/gmp/functions/gmp-fact.xml
@@ -41,6 +41,16 @@
+
+ &reftitle.errors;
+
+ Throws a ValueError if num is negative.
+
+
+ Prior to PHP 8.0.0, an E_WARNING was raised instead.
+
+
+
&reftitle.examples;
diff --git a/reference/gmp/functions/gmp-pow.xml b/reference/gmp/functions/gmp-pow.xml
index 51e7796afa5a..28981a3c19f5 100644
--- a/reference/gmp/functions/gmp-pow.xml
+++ b/reference/gmp/functions/gmp-pow.xml
@@ -51,6 +51,16 @@
+
+ &reftitle.errors;
+
+ Throws a ValueError if exponent is negative.
+
+
+ Prior to PHP 8.0.0, an E_WARNING was raised instead.
+
+
+
&reftitle.examples;
@@ -63,8 +73,6 @@ $pow1 = gmp_pow("2", 31);
echo gmp_strval($pow1) . "\n";
$pow2 = gmp_pow("0", 0);
echo gmp_strval($pow2) . "\n";
-$pow3 = gmp_pow("2", -1); // Negative exp, generates warning
-echo gmp_strval($pow3) . "\n";
?>
]]>
diff --git a/reference/gmp/functions/gmp-powm.xml b/reference/gmp/functions/gmp-powm.xml
index bb5dffa1cb5d..2511a2556008 100644
--- a/reference/gmp/functions/gmp-powm.xml
+++ b/reference/gmp/functions/gmp-powm.xml
@@ -64,6 +64,20 @@
+
+ &reftitle.errors;
+
+ Throws a ValueError if exponent is negative.
+
+
+ Throws a DivisionByZeroError if modulus
+ is 0.
+
+
+ Prior to PHP 8.0.0, an E_WARNING was raised instead.
+
+
+
&reftitle.examples;
diff --git a/reference/gmp/functions/gmp-root.xml b/reference/gmp/functions/gmp-root.xml
index 74b014cee2a7..6b7b50ba14b0 100644
--- a/reference/gmp/functions/gmp-root.xml
+++ b/reference/gmp/functions/gmp-root.xml
@@ -47,6 +47,17 @@
The integer component of the resultant root, as a GMP number.
+
+
+ &reftitle.errors;
+
+ Throws a ValueError if nth is less than 1,
+ or if nth is even and num is negative.
+
+
+ Prior to PHP 8.0.0, an E_WARNING was raised instead.
+
+