aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-11 18:34:03 +0000
committerMario <mario@mariovavti.com>2022-10-11 18:34:03 +0000
commit108a3efe0b6d37a7ed394a84c69b924ca727f17a (patch)
treeed9904767622d769fcee883d407310087ed7d57a /vendor/brick/math
parentccd826f63a7a4c7e442fab8a70d9c4c84808b417 (diff)
downloadvolse-hubzilla-108a3efe0b6d37a7ed394a84c69b924ca727f17a.tar.gz
volse-hubzilla-108a3efe0b6d37a7ed394a84c69b924ca727f17a.tar.bz2
volse-hubzilla-108a3efe0b6d37a7ed394a84c69b924ca727f17a.zip
update composer libs
Diffstat (limited to 'vendor/brick/math')
-rw-r--r--vendor/brick/math/CHANGELOG.md22
-rw-r--r--vendor/brick/math/SECURITY.md17
-rw-r--r--vendor/brick/math/composer.json6
-rw-r--r--vendor/brick/math/src/BigDecimal.php8
-rw-r--r--vendor/brick/math/src/BigInteger.php19
-rw-r--r--vendor/brick/math/src/BigNumber.php4
-rw-r--r--vendor/brick/math/src/BigRational.php11
-rw-r--r--vendor/brick/math/src/Internal/Calculator.php35
-rw-r--r--vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php6
-rw-r--r--vendor/brick/math/src/Internal/Calculator/NativeCalculator.php4
10 files changed, 62 insertions, 70 deletions
diff --git a/vendor/brick/math/CHANGELOG.md b/vendor/brick/math/CHANGELOG.md
index 03c3d824d..c5c5893b9 100644
--- a/vendor/brick/math/CHANGELOG.md
+++ b/vendor/brick/math/CHANGELOG.md
@@ -2,11 +2,29 @@
All notable changes to this project will be documented in this file.
+## [0.10.2](https://github.com/brick/math/releases/tag/0.10.2) - 2022-08-11
+
+👌 **Improvements**
+
+- `BigRational::toFloat()` now simplifies the fraction before performing division (#73) thanks to @olsavmic
+
+## [0.10.1](https://github.com/brick/math/releases/tag/0.10.1) - 2022-08-02
+
+✨ **New features**
+
+- `BigInteger::gcdMultiple()` returns the GCD of multiple `BigInteger` numbers
+
+## [0.10.0](https://github.com/brick/math/releases/tag/0.10.0) - 2022-06-18
+
+💥 **Breaking changes**
+
+- Minimum PHP version is now 7.4
+
## [0.9.3](https://github.com/brick/math/releases/tag/0.9.3) - 2021-08-15
🚀 **Compatibility with PHP 8.1**
-- Support for custom object serialization; this removes a warning on PHP 8.1 due to the `Serializable` interface being deprecated (thanks @TRowbotham)
+- Support for custom object serialization; this removes a warning on PHP 8.1 due to the `Serializable` interface being deprecated (#60) thanks @TRowbotham
## [0.9.2](https://github.com/brick/math/releases/tag/0.9.2) - 2021-01-20
@@ -16,7 +34,7 @@ All notable changes to this project will be documented in this file.
## [0.9.1](https://github.com/brick/math/releases/tag/0.9.1) - 2020-08-19
-✨ New features
+✨ **New features**
- `BigInteger::not()` returns the bitwise `NOT` value
diff --git a/vendor/brick/math/SECURITY.md b/vendor/brick/math/SECURITY.md
deleted file mode 100644
index cc8289bb5..000000000
--- a/vendor/brick/math/SECURITY.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-Only the last two release streams are supported.
-
-| Version | Supported |
-| ------- | ------------------ |
-| 0.9.x | :white_check_mark: |
-| 0.8.x | :white_check_mark: |
-| < 0.8 | :x: |
-
-## Reporting a Vulnerability
-
-To report a security vulnerability, please use the
-[Tidelift security contact](https://tidelift.com/security).
-Tidelift will coordinate the fix and disclosure.
diff --git a/vendor/brick/math/composer.json b/vendor/brick/math/composer.json
index ec196632f..a8124e921 100644
--- a/vendor/brick/math/composer.json
+++ b/vendor/brick/math/composer.json
@@ -14,13 +14,13 @@
],
"license": "MIT",
"require": {
- "php": "^7.1 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-json": "*"
},
"require-dev": {
- "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
+ "phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^2.2",
- "vimeo/psalm": "4.9.2"
+ "vimeo/psalm": "4.25.0"
},
"autoload": {
"psr-4": {
diff --git a/vendor/brick/math/src/BigDecimal.php b/vendor/brick/math/src/BigDecimal.php
index 78246500c..fd2babb86 100644
--- a/vendor/brick/math/src/BigDecimal.php
+++ b/vendor/brick/math/src/BigDecimal.php
@@ -22,19 +22,15 @@ final class BigDecimal extends BigNumber
* This is a string of digits with an optional leading minus sign.
* No leading zero must be present.
* No leading minus sign must be present if the value is 0.
- *
- * @var string
*/
- private $value;
+ private string $value;
/**
* The scale (number of digits after the decimal point) of this decimal number.
*
* This must be zero or more.
- *
- * @var int
*/
- private $scale;
+ private int $scale;
/**
* Protected constructor. Use a factory method to obtain an instance.
diff --git a/vendor/brick/math/src/BigInteger.php b/vendor/brick/math/src/BigInteger.php
index f213fbedb..f58e1c595 100644
--- a/vendor/brick/math/src/BigInteger.php
+++ b/vendor/brick/math/src/BigInteger.php
@@ -26,10 +26,8 @@ final class BigInteger extends BigNumber
*
* No leading zeros must be present.
* No leading minus sign must be present if the number is zero.
- *
- * @var string
*/
- private $value;
+ private string $value;
/**
* Protected constructor. Use a factory method to obtain an instance.
@@ -361,6 +359,21 @@ final class BigInteger extends BigNumber
return $ten;
}
+ public static function gcdMultiple(BigInteger $a, BigInteger ...$n): BigInteger
+ {
+ $result = $a;
+
+ foreach ($n as $next) {
+ $result = $result->gcd($next);
+
+ if ($result->isEqualTo(1)) {
+ return $result;
+ }
+ }
+
+ return $result;
+ }
+
/**
* Returns the sum of this number and the given one.
*
diff --git a/vendor/brick/math/src/BigNumber.php b/vendor/brick/math/src/BigNumber.php
index 38c8c554e..44f26e35a 100644
--- a/vendor/brick/math/src/BigNumber.php
+++ b/vendor/brick/math/src/BigNumber.php
@@ -81,9 +81,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
$throw();
}
- $getMatch = static function(string $value) use ($matches) : ?string {
- return isset($matches[$value]) && $matches[$value] !== '' ? $matches[$value] : null;
- };
+ $getMatch = static fn(string $value): ?string => (($matches[$value] ?? '') !== '') ? $matches[$value] : null;
$sign = $getMatch('sign');
$numerator = $getMatch('numerator');
diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php
index bee094f73..46257814d 100644
--- a/vendor/brick/math/src/BigRational.php
+++ b/vendor/brick/math/src/BigRational.php
@@ -20,17 +20,13 @@ final class BigRational extends BigNumber
{
/**
* The numerator.
- *
- * @var BigInteger
*/
- private $numerator;
+ private BigInteger $numerator;
/**
* The denominator. Always strictly positive.
- *
- * @var BigInteger
*/
- private $denominator;
+ private BigInteger $denominator;
/**
* Protected constructor. Use a factory method to obtain an instance.
@@ -433,7 +429,8 @@ final class BigRational extends BigNumber
*/
public function toFloat() : float
{
- return $this->numerator->toFloat() / $this->denominator->toFloat();
+ $simplified = $this->simplified();
+ return $simplified->numerator->toFloat() / $simplified->denominator->toFloat();
}
/**
diff --git a/vendor/brick/math/src/Internal/Calculator.php b/vendor/brick/math/src/Internal/Calculator.php
index a6eac799f..99bebbe5d 100644
--- a/vendor/brick/math/src/Internal/Calculator.php
+++ b/vendor/brick/math/src/Internal/Calculator.php
@@ -34,10 +34,8 @@ abstract class Calculator
/**
* The Calculator instance in use.
- *
- * @var Calculator|null
*/
- private static $instance;
+ private static ?Calculator $instance = null;
/**
* Sets the Calculator instance to use.
@@ -234,7 +232,7 @@ abstract class Calculator
* @param string $a The dividend.
* @param string $b The divisor, must not be zero.
*
- * @return string[] An array containing the quotient and remainder.
+ * @return array{string, string} An array containing the quotient and remainder.
*/
abstract public function divQR(string $a, string $b) : array;
@@ -283,9 +281,7 @@ abstract class Calculator
$modVal = $this->mod($x, $m);
}
- $x = '0';
- $y = '0';
- $g = $this->gcdExtended($modVal, $m, $x, $y);
+ [$g, $x] = $this->gcdExtended($modVal, $m);
if ($g !== '1') {
return null;
@@ -329,24 +325,21 @@ abstract class Calculator
return $this->gcd($b, $this->divR($a, $b));
}
- private function gcdExtended(string $a, string $b, string &$x, string &$y) : string
+ /**
+ * @return array{string, string, string} GCD, X, Y
+ */
+ private function gcdExtended(string $a, string $b) : array
{
if ($a === '0') {
- $x = '0';
- $y = '1';
-
- return $b;
+ return [$b, '0', '1'];
}
- $x1 = '0';
- $y1 = '0';
-
- $gcd = $this->gcdExtended($this->mod($b, $a), $a, $x1, $y1);
+ [$gcd, $x1, $y1] = $this->gcdExtended($this->mod($b, $a), $a);
$x = $this->sub($y1, $this->mul($this->divQ($b, $a), $x1));
$y = $x1;
- return $gcd;
+ return [$gcd, $x, $y];
}
/**
@@ -493,6 +486,8 @@ 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
{
@@ -616,9 +611,9 @@ abstract class Calculator
/**
* Performs a bitwise operation on a decimal number.
*
- * @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.
+ * @param 'and'|'or'|'xor' $operator The operator to use.
+ * @param string $a The left operand.
+ * @param string $b The right operand.
*
* @return string
*/
diff --git a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
index 6632b378a..34078687d 100644
--- a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
@@ -94,9 +94,6 @@ class BcMathCalculator extends Calculator
/**
* {@inheritdoc}
- *
- * @psalm-suppress InvalidNullableReturnType
- * @psalm-suppress NullableReturnStatement
*/
public function modPow(string $base, string $exp, string $mod) : string
{
@@ -105,9 +102,6 @@ class BcMathCalculator extends Calculator
/**
* {@inheritDoc}
- *
- * @psalm-suppress NullableReturnStatement
- * @psalm-suppress InvalidNullableReturnType
*/
public function sqrt(string $n) : string
{
diff --git a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
index 020a6338b..a7eb23b90 100644
--- a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
@@ -22,10 +22,8 @@ class NativeCalculator extends Calculator
* For addition, it is assumed that an extra digit can hold a carry (1) without overflowing.
* Example: 32-bit: max number 1,999,999,999 (9 digits + carry)
* 64-bit: max number 1,999,999,999,999,999,999 (18 digits + carry)
- *
- * @var int
*/
- private $maxDigits;
+ private int $maxDigits;
/**
* Class constructor.