Skip to content

Commit

Permalink
Use gmp operator overload instead of gmp_pow
Browse files Browse the repository at this point in the history
There is a bug in PHP 8.3.14 and 8.2.26 that causes gmp_pow to fail.
See php/php-src#16870

Using operator overloading (**) instead of gmp_pow may fix the issue.
See php/php-src#16870 (comment)
  • Loading branch information
kelvinmo committed Dec 11, 2024
1 parent 3008d7b commit 37ce733
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/SimpleJWT/Util/BigNum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 37ce733

Please sign in to comment.