aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math/src/Internal/Calculator.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-11 18:41:34 +0000
committerMario <mario@mariovavti.com>2022-10-11 18:41:34 +0000
commit10ba98c4f5ec4efe6272516de47f0ce128ef2902 (patch)
treefbbde69114acba764cf6b735433c53e099fd19c5 /vendor/brick/math/src/Internal/Calculator.php
parent108a3efe0b6d37a7ed394a84c69b924ca727f17a (diff)
downloadvolse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.tar.gz
volse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.tar.bz2
volse-hubzilla-10ba98c4f5ec4efe6272516de47f0ce128ef2902.zip
Revert "update composer libs"
This reverts commit 108a3efe0b6d37a7ed394a84c69b924ca727f17a.
Diffstat (limited to 'vendor/brick/math/src/Internal/Calculator.php')
-rw-r--r--vendor/brick/math/src/Internal/Calculator.php35
1 files changed, 20 insertions, 15 deletions
diff --git a/vendor/brick/math/src/Internal/Calculator.php b/vendor/brick/math/src/Internal/Calculator.php
index 99bebbe5d..a6eac799f 100644
--- a/vendor/brick/math/src/Internal/Calculator.php
+++ b/vendor/brick/math/src/Internal/Calculator.php
@@ -34,8 +34,10 @@ abstract class Calculator
/**
* The Calculator instance in use.
+ *
+ * @var Calculator|null
*/
- private static ?Calculator $instance = null;
+ private static $instance;
/**
* Sets the Calculator instance to use.
@@ -232,7 +234,7 @@ abstract class Calculator
* @param string $a The dividend.
* @param string $b The divisor, must not be zero.
*
- * @return array{string, string} An array containing the quotient and remainder.
+ * @return string[] An array containing the quotient and remainder.
*/
abstract public function divQR(string $a, string $b) : array;
@@ -281,7 +283,9 @@ abstract class Calculator
$modVal = $this->mod($x, $m);
}
- [$g, $x] = $this->gcdExtended($modVal, $m);
+ $x = '0';
+ $y = '0';
+ $g = $this->gcdExtended($modVal, $m, $x, $y);
if ($g !== '1') {
return null;
@@ -325,21 +329,24 @@ abstract class Calculator
return $this->gcd($b, $this->divR($a, $b));
}
- /**
- * @return array{string, string, string} GCD, X, Y
- */
- private function gcdExtended(string $a, string $b) : array
+ private function gcdExtended(string $a, string $b, string &$x, string &$y) : string
{
if ($a === '0') {
- return [$b, '0', '1'];
+ $x = '0';
+ $y = '1';
+
+ return $b;
}
- [$gcd, $x1, $y1] = $this->gcdExtended($this->mod($b, $a), $a);
+ $x1 = '0';
+ $y1 = '0';
+
+ $gcd = $this->gcdExtended($this->mod($b, $a), $a, $x1, $y1);
$x = $this->sub($y1, $this->mul($this->divQ($b, $a), $x1));
$y = $x1;
- return [$gcd, $x, $y];
+ return $gcd;
}
/**
@@ -486,8 +493,6 @@ abstract class Calculator
*
* @throws \InvalidArgumentException If the rounding mode is invalid.
* @throws RoundingNecessaryException If RoundingMode::UNNECESSARY is provided but rounding is necessary.
- *
- * @psalm-suppress ImpureFunctionCall
*/
final public function divRound(string $a, string $b, int $roundingMode) : string
{
@@ -611,9 +616,9 @@ abstract class Calculator
/**
* Performs a bitwise operation on a decimal number.
*
- * @param 'and'|'or'|'xor' $operator The operator to use.
- * @param string $a The left operand.
- * @param string $b The right operand.
+ * @param string $operator The operator to use, must be "and", "or" or "xor".
+ * @param string $a The left operand.
+ * @param string $b The right operand.
*
* @return string
*/