From a27dcfee91d261bed9274b8e8edb855f5c073e74 Mon Sep 17 00:00:00 2001 From: Kelvin Mo Date: Wed, 11 Dec 2024 20:32:35 +1100 Subject: [PATCH] Use gmp operator overload instead of gmp_pow for certain PHP versions (#215) Use gmp operator overload instead of gmp_pow for certain PHP versions --- .github/workflows/ci.yml | 1 + src/SimpleJWT/Util/BigNum.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edfa252..0a78b63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,7 @@ jobs: - 8.0 - 8.1 - 8.2 + - 8.3 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/src/SimpleJWT/Util/BigNum.php b/src/SimpleJWT/Util/BigNum.php index 3ca37a9..ebc4e96 100644 --- a/src/SimpleJWT/Util/BigNum.php +++ b/src/SimpleJWT/Util/BigNum.php @@ -217,6 +217,9 @@ protected function _div($a, $b) { function _pow($base, $exp) { if (is_object($exp) && ($exp instanceof \GMP)) $exp = gmp_intval($exp); + /** @disregard P1006 */ + if (version_compare(PHP_VERSION, '8.2.26', '==') || version_compare(PHP_VERSION, '8.3.14', '==')) + return ($base ** $exp); return gmp_pow($base, $exp); }