aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
committerMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
commite6dac085cb1d601da1fc63bfd59d811612fa6ef4 (patch)
treef5b704b613c9c8d347857b4e7f8dd0b19cdd7df3 /vendor/brick
parentf5f357060bf0ebcb0b8352519375953d993437e7 (diff)
downloadvolse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.gz
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.bz2
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.zip
update composer libs
Diffstat (limited to 'vendor/brick')
-rw-r--r--vendor/brick/math/CHANGELOG.md152
-rw-r--r--vendor/brick/math/composer.json2
-rw-r--r--vendor/brick/math/random-tests.php194
-rw-r--r--vendor/brick/math/src/BigDecimal.php36
-rw-r--r--vendor/brick/math/src/BigInteger.php33
-rw-r--r--vendor/brick/math/src/BigRational.php34
-rw-r--r--vendor/brick/math/src/Internal/Calculator.php5
-rw-r--r--vendor/brick/math/src/Internal/Calculator/NativeCalculator.php2
8 files changed, 187 insertions, 271 deletions
diff --git a/vendor/brick/math/CHANGELOG.md b/vendor/brick/math/CHANGELOG.md
index 61ab09d18..03c3d824d 100644
--- a/vendor/brick/math/CHANGELOG.md
+++ b/vendor/brick/math/CHANGELOG.md
@@ -2,6 +2,18 @@
All notable changes to this project will be documented in this file.
+## [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)
+
+## [0.9.2](https://github.com/brick/math/releases/tag/0.9.2) - 2021-01-20
+
+🐛 **Bug fix**
+
+- Incorrect results could be returned when using the BCMath calculator, with a default scale set with `bcscale()`, on PHP >= 7.2 (#55).
+
## [0.9.1](https://github.com/brick/math/releases/tag/0.9.1) - 2020-08-19
✨ New features
@@ -24,6 +36,76 @@ All notable changes to this project will be documented in this file.
- Deprecated method `BigInteger::powerMod()` has been removed - use `modPow()` instead
- Deprecated method `BigInteger::parse()` has been removed - use `fromBase()` instead
+## [0.8.17](https://github.com/brick/math/releases/tag/0.8.17) - 2020-08-19
+
+🐛 **Bug fix**
+
+- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers
+- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available
+
+## [0.8.16](https://github.com/brick/math/releases/tag/0.8.16) - 2020-08-18
+
+🚑 **Critical fix**
+
+- This version reintroduces the deprecated `BigInteger::parse()` method, that has been removed by mistake in version `0.8.9` and should have lasted for the whole `0.8` release cycle.
+
+✨ **New features**
+
+- `BigInteger::modInverse()` calculates a modular multiplicative inverse
+- `BigInteger::fromBytes()` creates a `BigInteger` from a byte string
+- `BigInteger::toBytes()` converts a `BigInteger` to a byte string
+- `BigInteger::randomBits()` creates a pseudo-random `BigInteger` of a given bit length
+- `BigInteger::randomRange()` creates a pseudo-random `BigInteger` between two bounds
+
+💩 **Deprecations**
+
+- `BigInteger::powerMod()` is now deprecated in favour of `modPow()`
+
+## [0.8.15](https://github.com/brick/math/releases/tag/0.8.15) - 2020-04-15
+
+🐛 **Fixes**
+
+- added missing `ext-json` requirement, due to `BigNumber` implementing `JsonSerializable`
+
+⚡️ **Optimizations**
+
+- additional optimization in `BigInteger::remainder()`
+
+## [0.8.14](https://github.com/brick/math/releases/tag/0.8.14) - 2020-02-18
+
+✨ **New features**
+
+- `BigInteger::getLowestSetBit()` returns the index of the rightmost one bit
+
+## [0.8.13](https://github.com/brick/math/releases/tag/0.8.13) - 2020-02-16
+
+✨ **New features**
+
+- `BigInteger::isEven()` tests whether the number is even
+- `BigInteger::isOdd()` tests whether the number is odd
+- `BigInteger::testBit()` tests if a bit is set
+- `BigInteger::getBitLength()` returns the number of bits in the minimal representation of the number
+
+## [0.8.12](https://github.com/brick/math/releases/tag/0.8.12) - 2020-02-03
+
+🛠️ **Maintenance release**
+
+Classes are now annotated for better static analysis with [psalm](https://psalm.dev/).
+
+This is a maintenance release: no bug fixes, no new features, no breaking changes.
+
+## [0.8.11](https://github.com/brick/math/releases/tag/0.8.11) - 2020-01-23
+
+✨ **New feature**
+
+`BigInteger::powerMod()` performs a power-with-modulo operation. Useful for crypto.
+
+## [0.8.10](https://github.com/brick/math/releases/tag/0.8.10) - 2020-01-21
+
+✨ **New feature**
+
+`BigInteger::mod()` returns the **modulo** of two numbers. The *modulo* differs from the *remainder* when the signs of the operands are different.
+
## [0.8.9](https://github.com/brick/math/releases/tag/0.8.9) - 2020-01-08
⚡️ **Performance improvements**
@@ -96,76 +178,6 @@ Thanks @manowark 👍
- Further improvement of `toInt()` performance
- `NativeCalculator` can now perform some multiplications more efficiently
-## [0.8.17](https://github.com/brick/math/releases/tag/0.8.17) - 2020-08-19
-
-🐛 **Bug fix**
-
-- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers
-- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available
-
-## [0.8.16](https://github.com/brick/math/releases/tag/0.8.16) - 2020-08-18
-
-🚑 **Critical fix**
-
-- This version reintroduces the deprecated `BigInteger::parse()` method, that has been removed by mistake in version `0.8.9` and should have lasted for the whole `0.8` release cycle.
-
-✨ **New features**
-
-- `BigInteger::modInverse()` calculates a modular multiplicative inverse
-- `BigInteger::fromBytes()` creates a `BigInteger` from a byte string
-- `BigInteger::toBytes()` converts a `BigInteger` to a byte string
-- `BigInteger::randomBits()` creates a pseudo-random `BigInteger` of a given bit length
-- `BigInteger::randomRange()` creates a pseudo-random `BigInteger` between two bounds
-
-💩 **Deprecations**
-
-- `BigInteger::powerMod()` is now deprecated in favour of `modPow()`
-
-## [0.8.15](https://github.com/brick/math/releases/tag/0.8.15) - 2020-04-15
-
-🐛 **Fixes**
-
-- added missing `ext-json` requirement, due to `BigNumber` implementing `JsonSerializable`
-
-⚡️ **Optimizations**
-
-- additional optimization in `BigInteger::remainder()`
-
-## [0.8.14](https://github.com/brick/math/releases/tag/0.8.14) - 2020-02-18
-
-✨ **New features**
-
-- `BigInteger::getLowestSetBit()` returns the index of the rightmost one bit
-
-## [0.8.13](https://github.com/brick/math/releases/tag/0.8.13) - 2020-02-16
-
-✨ **New features**
-
-- `BigInteger::isEven()` tests whether the number is even
-- `BigInteger::isOdd()` tests whether the number is odd
-- `BigInteger::testBit()` tests if a bit is set
-- `BigInteger::getBitLength()` returns the number of bits in the minimal representation of the number
-
-## [0.8.12](https://github.com/brick/math/releases/tag/0.8.12) - 2020-02-03
-
-🛠️ **Maintenance release**
-
-Classes are now annotated for better static analysis with [psalm](https://psalm.dev/).
-
-This is a maintenance release: no bug fixes, no new features, no breaking changes.
-
-## [0.8.11](https://github.com/brick/math/releases/tag/0.8.11) - 2020-01-23
-
-✨ **New feature**
-
-`BigInteger::powerMod()` performs a power-with-modulo operation. Useful for crypto.
-
-## [0.8.10](https://github.com/brick/math/releases/tag/0.8.10) - 2020-01-21
-
-✨ **New feature**
-
-`BigInteger::mod()` returns the **modulo** of two numbers. The *modulo* differs from the *remainder* when the signs of the operands are different.
-
## [0.8.1](https://github.com/brick/math/releases/tag/0.8.1) - 2018-11-07
Performance optimization of `toInt()` methods.
diff --git a/vendor/brick/math/composer.json b/vendor/brick/math/composer.json
index c89955d12..ec196632f 100644
--- a/vendor/brick/math/composer.json
+++ b/vendor/brick/math/composer.json
@@ -20,7 +20,7 @@
"require-dev": {
"phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
"php-coveralls/php-coveralls": "^2.2",
- "vimeo/psalm": "4.3.2"
+ "vimeo/psalm": "4.9.2"
},
"autoload": {
"psr-4": {
diff --git a/vendor/brick/math/random-tests.php b/vendor/brick/math/random-tests.php
deleted file mode 100644
index d9053fc11..000000000
--- a/vendor/brick/math/random-tests.php
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-
-/**
- * This script stress tests calculators with random large numbers and ensures that all implementations return the same
- * results. It is designed to run in an infinite loop unless a bug is found.
- */
-
-declare(strict_types=1);
-
-require __DIR__ . '/vendor/autoload.php';
-
-use Brick\Math\Internal\Calculator;
-
-(new class(30) { // max digits
- private $gmp;
- private $bcmath;
- private $native;
-
- private $maxDigits;
-
- public function __construct(int $maxDigits)
- {
- $this->gmp = new Calculator\GmpCalculator();
- $this->bcmath = new Calculator\BcMathCalculator();
- $this->native = new Calculator\NativeCalculator();
-
- $this->maxDigits = $maxDigits;
- }
-
- public function __invoke() : void
- {
- for (;;) {
- $a = $this->generateRandomNumber();
- $b = $this->generateRandomNumber();
- $c = $this->generateRandomNumber();
-
- $this->runTests($a, $b);
- $this->runTests($b, $a);
-
- if ($a !== '0') {
- $this->runTests("-$a", $b);
- $this->runTests($b, "-$a");
- }
-
- if ($b !== '0') {
- $this->runTests($a, "-$b");
- $this->runTests("-$b", $a);
- }
-
- if ($a !== '0' && $b !== '0') {
- $this->runTests("-$a", "-$b");
- $this->runTests("-$b", "-$a");
- }
-
- if ($c !== '0') {
- $this->test("$a POW $b MOD $c", function(Calculator $calc) use($a, $b, $c) {
- return $calc->modPow($a, $b, $c);
- });
- }
- }
- }
-
- /**
- * @param string $a The left operand.
- * @param string $b The right operand.
- */
- private function runTests(string $a, string $b) : void
- {
- $this->test("$a + $b", function(Calculator $c) use($a, $b) {
- return $c->add($a, $b);
- });
-
- $this->test("$a - $b", function(Calculator $c) use($a, $b) {
- return $c->sub($a, $b);
- });
-
- $this->test("$a * $b", function(Calculator $c) use($a, $b) {
- return $c->mul($a, $b);
- });
-
- if ($b !== '0') {
- $this->test("$a / $b", function(Calculator $c) use($a, $b) {
- return $c->divQR($a, $b);
- });
-
- $this->test("$a MOD $b", function(Calculator $c) use($a, $b) {
- return $c->mod($a, $b);
- });
- }
-
- if ($b !== '0' && $b[0] !== '-') {
- $this->test("INV $a MOD $b", function(Calculator $c) use($a, $b) {
- return $c->modInverse($a, $b);
- });
- }
-
- $this->test("GCD $a, $b", function(Calculator $c) use($a, $b) {
- return $c->gcd($a, $b);
- });
-
- if ($a[0] !== '-') {
- $this->test("SQRT $a", function(Calculator $c) use($a, $b) {
- return $c->sqrt($a);
- });
- }
-
- $this->test("$a AND $b", function(Calculator $c) use($a, $b) {
- return $c->and($a, $b);
- });
-
- $this->test("$a OR $b", function(Calculator $c) use($a, $b) {
- return $c->or($a, $b);
- });
-
- $this->test("$a XOR $b", function(Calculator $c) use($a, $b) {
- return $c->xor($a, $b);
- });
- }
-
- /**
- * @param string $test A string representing the test being executed.
- * @param Closure $callback A callback function accepting a Calculator instance and returning a calculation result.
- */
- private function test(string $test, Closure $callback) : void
- {
- static $testCounter = 0;
- static $lastOutputTime = 0.0;
- static $currentSecond = 0;
- static $currentSecondTestCounter = 0;
- static $testsPerSecond = 0;
-
- $gmpResult = $callback($this->gmp);
- $bcmathResult = $callback($this->bcmath);
- $nativeResult = $callback($this->native);
-
- if ($gmpResult !== $bcmathResult) {
- self::failure('GMP', 'BCMath', $test);
- }
-
- if ($gmpResult !== $nativeResult) {
- self::failure('GMP', 'Native', $test);
- }
-
- $testCounter++;
- $currentSecondTestCounter++;
-
- $time = microtime(true);
- $second = (int) $time;
-
- if ($second !== $currentSecond) {
- $currentSecond = $second;
- $testsPerSecond = $currentSecondTestCounter;
- $currentSecondTestCounter = 0;
- }
-
- if ($time - $lastOutputTime >= 0.1) {
- echo "\r", number_format($testCounter), ' (', number_format($testsPerSecond) . ' / s)';
- $lastOutputTime = $time;
- }
- }
-
- /**
- * @param string $c1 The name of the first calculator.
- * @param string $c2 The name of the second calculator.
- * @param string $test A string representing the test being executed.
- */
- private static function failure(string $c1, string $c2, string $test) : void
- {
- echo PHP_EOL;
- echo 'FAILURE!', PHP_EOL;
- echo $c1, ' vs ', $c2, PHP_EOL;
- echo $test, PHP_EOL;
- die;
- }
-
- private function generateRandomNumber() : string
- {
- $length = random_int(1, $this->maxDigits);
-
- $number = '';
-
- for ($i = 0; $i < $length; $i++) {
- $number .= random_int(0, 9);
- }
-
- $number = ltrim($number, '0');
-
- if ($number === '') {
- return '0';
- }
-
- return $number;
- }
-})();
diff --git a/vendor/brick/math/src/BigDecimal.php b/vendor/brick/math/src/BigDecimal.php
index 7707b166e..78246500c 100644
--- a/vendor/brick/math/src/BigDecimal.php
+++ b/vendor/brick/math/src/BigDecimal.php
@@ -753,6 +753,40 @@ final class BigDecimal extends BigNumber
}
/**
+ * This method is required for serializing the object and SHOULD NOT be accessed directly.
+ *
+ * @internal
+ *
+ * @return array{value: string, scale: int}
+ */
+ public function __serialize(): array
+ {
+ return ['value' => $this->value, 'scale' => $this->scale];
+ }
+
+ /**
+ * This method is only here to allow unserializing the object and cannot be accessed directly.
+ *
+ * @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
+ *
+ * @param array{value: string, scale: int} $data
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function __unserialize(array $data): void
+ {
+ if (isset($this->value)) {
+ throw new \LogicException('__unserialize() is an internal function, it must not be called directly.');
+ }
+
+ $this->value = $data['value'];
+ $this->scale = $data['scale'];
+ }
+
+ /**
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
@@ -794,7 +828,7 @@ final class BigDecimal extends BigNumber
* @param BigDecimal $x The first decimal number.
* @param BigDecimal $y The second decimal number.
*
- * @return array{0: string, 1: string} The scaled integer values of $x and $y.
+ * @return array{string, string} The scaled integer values of $x and $y.
*/
private function scaleValues(BigDecimal $x, BigDecimal $y) : array
{
diff --git a/vendor/brick/math/src/BigInteger.php b/vendor/brick/math/src/BigInteger.php
index 0dcc8f3b3..f213fbedb 100644
--- a/vendor/brick/math/src/BigInteger.php
+++ b/vendor/brick/math/src/BigInteger.php
@@ -1117,6 +1117,39 @@ final class BigInteger extends BigNumber
}
/**
+ * This method is required for serializing the object and SHOULD NOT be accessed directly.
+ *
+ * @internal
+ *
+ * @return array{value: string}
+ */
+ public function __serialize(): array
+ {
+ return ['value' => $this->value];
+ }
+
+ /**
+ * This method is only here to allow unserializing the object and cannot be accessed directly.
+ *
+ * @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
+ *
+ * @param array{value: string} $data
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function __unserialize(array $data): void
+ {
+ if (isset($this->value)) {
+ throw new \LogicException('__unserialize() is an internal function, it must not be called directly.');
+ }
+
+ $this->value = $data['value'];
+ }
+
+ /**
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php
index 7fbabd7f1..bee094f73 100644
--- a/vendor/brick/math/src/BigRational.php
+++ b/vendor/brick/math/src/BigRational.php
@@ -452,6 +452,40 @@ final class BigRational extends BigNumber
}
/**
+ * This method is required for serializing the object and SHOULD NOT be accessed directly.
+ *
+ * @internal
+ *
+ * @return array{numerator: BigInteger, denominator: BigInteger}
+ */
+ public function __serialize(): array
+ {
+ return ['numerator' => $this->numerator, 'denominator' => $this->denominator];
+ }
+
+ /**
+ * This method is only here to allow unserializing the object and cannot be accessed directly.
+ *
+ * @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
+ *
+ * @param array{numerator: BigInteger, denominator: BigInteger} $data
+ *
+ * @return void
+ *
+ * @throws \LogicException
+ */
+ public function __unserialize(array $data): void
+ {
+ if (isset($this->numerator)) {
+ throw new \LogicException('__unserialize() is an internal function, it must not be called directly.');
+ }
+
+ $this->numerator = $data['numerator'];
+ $this->denominator = $data['denominator'];
+ }
+
+ /**
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
diff --git a/vendor/brick/math/src/Internal/Calculator.php b/vendor/brick/math/src/Internal/Calculator.php
index 99b478193..a6eac799f 100644
--- a/vendor/brick/math/src/Internal/Calculator.php
+++ b/vendor/brick/math/src/Internal/Calculator.php
@@ -99,7 +99,7 @@ abstract class Calculator
* @param string $a The first operand.
* @param string $b The second operand.
*
- * @return array{0: bool, 1: bool, 2: string, 3: string} Whether $a and $b are negative, followed by their digits.
+ * @return array{bool, bool, string, string} Whether $a and $b are negative, followed by their digits.
*/
final protected function init(string $a, string $b) : array
{
@@ -677,9 +677,6 @@ abstract class Calculator
}
/**
- * @psalm-suppress InvalidOperand
- * @see https://github.com/vimeo/psalm/issues/4456
- *
* @param string $number A positive, binary number.
*
* @return string
diff --git a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
index a5f8a9b48..020a6338b 100644
--- a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
@@ -610,7 +610,7 @@ class NativeCalculator extends Calculator
* @param string $a The first operand.
* @param string $b The second operand.
*
- * @return array{0: string, 1: string, 2: int}
+ * @return array{string, string, int}
*/
private function pad(string $a, string $b) : array
{