aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-02-15 18:27:20 +0000
committerMario <mario@mariovavti.com>2021-02-15 18:27:20 +0000
commit18c8f1b903e90ca3632520b90d21ec3770bf6e0b (patch)
tree542ce373170e5693d32516aa11d7569ed312ad03 /vendor/brick/math
parent4171a0136ad4f14bdd5d7621b4c7decd3e942c8c (diff)
downloadvolse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.tar.gz
volse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.tar.bz2
volse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.zip
composer update brick/math
Diffstat (limited to 'vendor/brick/math')
-rw-r--r--vendor/brick/math/CHANGELOG.md403
-rw-r--r--vendor/brick/math/SECURITY.md3
-rw-r--r--vendor/brick/math/composer.json6
-rw-r--r--vendor/brick/math/psalm-baseline.xml40
-rw-r--r--vendor/brick/math/psalm.xml56
-rw-r--r--vendor/brick/math/random-tests.php26
-rw-r--r--vendor/brick/math/src/BigDecimal.php22
-rw-r--r--vendor/brick/math/src/BigInteger.php25
-rw-r--r--vendor/brick/math/src/BigNumber.php42
-rw-r--r--vendor/brick/math/src/BigRational.php16
-rw-r--r--vendor/brick/math/src/Internal/Calculator.php5
-rw-r--r--vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php26
-rw-r--r--vendor/brick/math/src/Internal/Calculator/NativeCalculator.php28
13 files changed, 550 insertions, 148 deletions
diff --git a/vendor/brick/math/CHANGELOG.md b/vendor/brick/math/CHANGELOG.md
new file mode 100644
index 000000000..61ab09d18
--- /dev/null
+++ b/vendor/brick/math/CHANGELOG.md
@@ -0,0 +1,403 @@
+# Changelog
+
+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
+
+- `BigInteger::not()` returns the bitwise `NOT` value
+
+🐛 **Bug fixes**
+
+- `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.9.0](https://github.com/brick/math/releases/tag/0.9.0) - 2020-08-18
+
+👌 **Improvements**
+
+- `BigNumber::of()` now accepts `.123` and `123.` formats, both of which return a `BigDecimal`
+
+💥 **Breaking changes**
+
+- Deprecated method `BigInteger::powerMod()` has been removed - use `modPow()` instead
+- Deprecated method `BigInteger::parse()` has been removed - use `fromBase()` instead
+
+## [0.8.9](https://github.com/brick/math/releases/tag/0.8.9) - 2020-01-08
+
+⚡️ **Performance improvements**
+
+A few additional optimizations in `BigInteger` and `BigDecimal` when one of the operands can be returned as is. Thanks to @tomtomsen in #24.
+
+## [0.8.8](https://github.com/brick/math/releases/tag/0.8.8) - 2019-04-25
+
+🐛 **Bug fixes**
+
+- `BigInteger::toBase()` could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected)
+
+✨ **New features**
+
+- `BigInteger::toArbitraryBase()` converts a number to an arbitrary base, using a custom alphabet
+- `BigInteger::fromArbitraryBase()` converts a string in an arbitrary base, using a custom alphabet, back to a number
+
+These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation.
+
+💩 **Deprecations**
+
+- `BigInteger::parse()` is now deprecated in favour of `fromBase()`
+
+`BigInteger::fromBase()` works the same way as `parse()`, with 2 minor differences:
+
+- the `$base` parameter is required, it does not default to `10`
+- it throws a `NumberFormatException` instead of an `InvalidArgumentException` when the number is malformed
+
+## [0.8.7](https://github.com/brick/math/releases/tag/0.8.7) - 2019-04-20
+
+**Improvements**
+
+- Safer conversion from `float` when using custom locales
+- **Much faster** `NativeCalculator` implementation 🚀
+
+You can expect **at least a 3x performance improvement** for common arithmetic operations when using the library on systems without GMP or BCMath; it gets exponentially faster on multiplications with a high number of digits. This is due to calculations now being performed on whole blocks of digits (the block size depending on the platform, 32-bit or 64-bit) instead of digit-by-digit as before.
+
+## [0.8.6](https://github.com/brick/math/releases/tag/0.8.6) - 2019-04-11
+
+**New method**
+
+`BigNumber::sum()` returns the sum of one or more numbers.
+
+## [0.8.5](https://github.com/brick/math/releases/tag/0.8.5) - 2019-02-12
+
+**Bug fix**: `of()` factory methods could fail when passing a `float` in environments using a `LC_NUMERIC` locale with a decimal separator other than `'.'` (#20).
+
+Thanks @manowark 👍
+
+## [0.8.4](https://github.com/brick/math/releases/tag/0.8.4) - 2018-12-07
+
+**New method**
+
+`BigDecimal::sqrt()` calculates the square root of a decimal number, to a given scale.
+
+## [0.8.3](https://github.com/brick/math/releases/tag/0.8.3) - 2018-12-06
+
+**New method**
+
+`BigInteger::sqrt()` calculates the square root of a number (thanks @peter279k).
+
+**New exception**
+
+`NegativeNumberException` is thrown when calling `sqrt()` on a negative number.
+
+## [0.8.2](https://github.com/brick/math/releases/tag/0.8.2) - 2018-11-08
+
+**Performance update**
+
+- 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.
+
+## [0.8.0](https://github.com/brick/math/releases/tag/0.8.0) - 2018-10-13
+
+**Breaking changes**
+
+The following deprecated methods have been removed. Use the new method name instead:
+
+| Method removed | Replacement method |
+| --- | --- |
+| `BigDecimal::getIntegral()` | `BigDecimal::getIntegralPart()` |
+| `BigDecimal::getFraction()` | `BigDecimal::getFractionalPart()` |
+
+---
+
+**New features**
+
+`BigInteger` has been augmented with 5 new methods for bitwise operations:
+
+| New method | Description |
+| --- | --- |
+| `and()` | performs a bitwise `AND` operation on two numbers |
+| `or()` | performs a bitwise `OR` operation on two numbers |
+| `xor()` | performs a bitwise `XOR` operation on two numbers |
+| `shiftedLeft()` | returns the number shifted left by a number of bits |
+| `shiftedRight()` | returns the number shifted right by a number of bits |
+
+Thanks to @DASPRiD 👍
+
+## [0.7.3](https://github.com/brick/math/releases/tag/0.7.3) - 2018-08-20
+
+**New method:** `BigDecimal::hasNonZeroFractionalPart()`
+
+**Renamed/deprecated methods:**
+
+- `BigDecimal::getIntegral()` has been renamed to `getIntegralPart()` and is now deprecated
+- `BigDecimal::getFraction()` has been renamed to `getFractionalPart()` and is now deprecated
+
+## [0.7.2](https://github.com/brick/math/releases/tag/0.7.2) - 2018-07-21
+
+**Performance update**
+
+`BigInteger::parse()` and `toBase()` now use GMP's built-in base conversion features when available.
+
+## [0.7.1](https://github.com/brick/math/releases/tag/0.7.1) - 2018-03-01
+
+This is a maintenance release, no code has been changed.
+
+- When installed with `--no-dev`, the autoloader does not autoload tests anymore
+- Tests and other files unnecessary for production are excluded from the dist package
+
+This will help make installations more compact.
+
+## [0.7.0](https://github.com/brick/math/releases/tag/0.7.0) - 2017-10-02
+
+Methods renamed:
+
+- `BigNumber:sign()` has been renamed to `getSign()`
+- `BigDecimal::unscaledValue()` has been renamed to `getUnscaledValue()`
+- `BigDecimal::scale()` has been renamed to `getScale()`
+- `BigDecimal::integral()` has been renamed to `getIntegral()`
+- `BigDecimal::fraction()` has been renamed to `getFraction()`
+- `BigRational::numerator()` has been renamed to `getNumerator()`
+- `BigRational::denominator()` has been renamed to `getDenominator()`
+
+Classes renamed:
+
+- `ArithmeticException` has been renamed to `MathException`
+
+## [0.6.2](https://github.com/brick/math/releases/tag/0.6.2) - 2017-10-02
+
+The base class for all exceptions is now `MathException`.
+`ArithmeticException` has been deprecated, and will be removed in 0.7.0.
+
+## [0.6.1](https://github.com/brick/math/releases/tag/0.6.1) - 2017-10-02
+
+A number of methods have been renamed:
+
+- `BigNumber:sign()` is deprecated; use `getSign()` instead
+- `BigDecimal::unscaledValue()` is deprecated; use `getUnscaledValue()` instead
+- `BigDecimal::scale()` is deprecated; use `getScale()` instead
+- `BigDecimal::integral()` is deprecated; use `getIntegral()` instead
+- `BigDecimal::fraction()` is deprecated; use `getFraction()` instead
+- `BigRational::numerator()` is deprecated; use `getNumerator()` instead
+- `BigRational::denominator()` is deprecated; use `getDenominator()` instead
+
+The old methods will be removed in version 0.7.0.
+
+## [0.6.0](https://github.com/brick/math/releases/tag/0.6.0) - 2017-08-25
+
+- Minimum PHP version is now [7.1](https://gophp71.org/); for PHP 5.6 and PHP 7.0 support, use version `0.5`
+- Deprecated method `BigDecimal::withScale()` has been removed; use `toScale()` instead
+- Method `BigNumber::toInteger()` has been renamed to `toInt()`
+
+## [0.5.4](https://github.com/brick/math/releases/tag/0.5.4) - 2016-10-17
+
+`BigNumber` classes now implement [JsonSerializable](http://php.net/manual/en/class.jsonserializable.php).
+The JSON output is always a string.
+
+## [0.5.3](https://github.com/brick/math/releases/tag/0.5.3) - 2016-03-31
+
+This is a bugfix release. Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6.
+
+## [0.5.2](https://github.com/brick/math/releases/tag/0.5.2) - 2015-08-06
+
+The `$scale` parameter of `BigDecimal::dividedBy()` is now optional again.
+
+## [0.5.1](https://github.com/brick/math/releases/tag/0.5.1) - 2015-07-05
+
+**New method: `BigNumber::toScale()`**
+
+This allows to convert any `BigNumber` to a `BigDecimal` with a given scale, using rounding if necessary.
+
+## [0.5.0](https://github.com/brick/math/releases/tag/0.5.0) - 2015-07-04
+
+**New features**
+- Common `BigNumber` interface for all classes, with the following methods:
+ - `sign()` and derived methods (`isZero()`, `isPositive()`, ...)
+ - `compareTo()` and derived methods (`isEqualTo()`, `isGreaterThan()`, ...) that work across different `BigNumber` types
+ - `toBigInteger()`, `toBigDecimal()`, `toBigRational`() conversion methods
+ - `toInteger()` and `toFloat()` conversion methods to native types
+- Unified `of()` behaviour: every class now accepts any type of number, provided that it can be safely converted to the current type
+- New method: `BigDecimal::exactlyDividedBy()`; this method automatically computes the scale of the result, provided that the division yields a finite number of digits
+- New methods: `BigRational::quotient()` and `remainder()`
+- Fine-grained exceptions: `DivisionByZeroException`, `RoundingNecessaryException`, `NumberFormatException`
+- Factory methods `zero()`, `one()` and `ten()` available in all classes
+- Rounding mode reintroduced in `BigInteger::dividedBy()`
+
+This release also comes with many performance improvements.
+
+---
+
+**Breaking changes**
+- `BigInteger`:
+ - `getSign()` is renamed to `sign()`
+ - `toString()` is renamed to `toBase()`
+ - `BigInteger::dividedBy()` now throws an exception by default if the remainder is not zero; use `quotient()` to get the previous behaviour
+- `BigDecimal`:
+ - `getSign()` is renamed to `sign()`
+ - `getUnscaledValue()` is renamed to `unscaledValue()`
+ - `getScale()` is renamed to `scale()`
+ - `getIntegral()` is renamed to `integral()`
+ - `getFraction()` is renamed to `fraction()`
+ - `divideAndRemainder()` is renamed to `quotientAndRemainder()`
+ - `dividedBy()` now takes a **mandatory** `$scale` parameter **before** the rounding mode
+ - `toBigInteger()` does not accept a `$roundingMode` parameter any more
+ - `toBigRational()` does not simplify the fraction any more; explicitly add `->simplified()` to get the previous behaviour
+- `BigRational`:
+ - `getSign()` is renamed to `sign()`
+ - `getNumerator()` is renamed to `numerator()`
+ - `getDenominator()` is renamed to `denominator()`
+ - `of()` is renamed to `nd()`, while `parse()` is renamed to `of()`
+- Miscellaneous:
+ - `ArithmeticException` is moved to an `Exception\` sub-namespace
+ - `of()` factory methods now throw `NumberFormatException` instead of `InvalidArgumentException`
+
+## [0.4.3](https://github.com/brick/math/releases/tag/0.4.3) - 2016-03-31
+
+Backport of two bug fixes from the 0.5 branch:
+- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected
+- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6.
+
+## [0.4.2](https://github.com/brick/math/releases/tag/0.4.2) - 2015-06-16
+
+New method: `BigDecimal::stripTrailingZeros()`
+
+## [0.4.1](https://github.com/brick/math/releases/tag/0.4.1) - 2015-06-12
+
+Introducing a `BigRational` class, to perform calculations on fractions of any size.
+
+## [0.4.0](https://github.com/brick/math/releases/tag/0.4.0) - 2015-06-12
+
+Rounding modes have been removed from `BigInteger`, and are now a concept specific to `BigDecimal`.
+
+`BigInteger::dividedBy()` now always returns the quotient of the division.
+
+## [0.3.5](https://github.com/brick/math/releases/tag/0.3.5) - 2016-03-31
+
+Backport of two bug fixes from the 0.5 branch:
+
+- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected
+- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6.
+
+## [0.3.4](https://github.com/brick/math/releases/tag/0.3.4) - 2015-06-11
+
+New methods:
+- `BigInteger::remainder()` returns the remainder of a division only
+- `BigInteger::gcd()` returns the greatest common divisor of two numbers
+
+## [0.3.3](https://github.com/brick/math/releases/tag/0.3.3) - 2015-06-07
+
+Fix `toString()` not handling negative numbers.
+
+## [0.3.2](https://github.com/brick/math/releases/tag/0.3.2) - 2015-06-07
+
+`BigInteger` and `BigDecimal` now have a `getSign()` method that returns:
+- `-1` if the number is negative
+- `0` if the number is zero
+- `1` if the number is positive
+
+## [0.3.1](https://github.com/brick/math/releases/tag/0.3.1) - 2015-06-05
+
+Minor performance improvements
+
+## [0.3.0](https://github.com/brick/math/releases/tag/0.3.0) - 2015-06-04
+
+The `$roundingMode` and `$scale` parameters have been swapped in `BigDecimal::dividedBy()`.
+
+## [0.2.2](https://github.com/brick/math/releases/tag/0.2.2) - 2015-06-04
+
+Stronger immutability guarantee for `BigInteger` and `BigDecimal`.
+
+So far, it would have been possible to break immutability of these classes by calling the `unserialize()` internal function. This release fixes that.
+
+## [0.2.1](https://github.com/brick/math/releases/tag/0.2.1) - 2015-06-02
+
+Added `BigDecimal::divideAndRemainder()`
+
+## [0.2.0](https://github.com/brick/math/releases/tag/0.2.0) - 2015-05-22
+
+- `min()` and `max()` do not accept an `array` any more, but a variable number of parameters
+- **minimum PHP version is now 5.6**
+- continuous integration with PHP 7
+
+## [0.1.1](https://github.com/brick/math/releases/tag/0.1.1) - 2014-09-01
+
+- Added `BigInteger::power()`
+- Added HHVM support
+
+## [0.1.0](https://github.com/brick/math/releases/tag/0.1.0) - 2014-08-31
+
+First beta release.
+
diff --git a/vendor/brick/math/SECURITY.md b/vendor/brick/math/SECURITY.md
index 6bdc74f0d..cc8289bb5 100644
--- a/vendor/brick/math/SECURITY.md
+++ b/vendor/brick/math/SECURITY.md
@@ -2,10 +2,11 @@
## Supported Versions
-Only the latest release stream is supported.
+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: |
diff --git a/vendor/brick/math/composer.json b/vendor/brick/math/composer.json
index d347b6bde..c89955d12 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.1 || ^8.0",
"ext-json": "*"
},
"require-dev": {
- "phpunit/phpunit": "^7.5.15|^8.5",
+ "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.0",
"php-coveralls/php-coveralls": "^2.2",
- "vimeo/psalm": "^3.5"
+ "vimeo/psalm": "4.3.2"
},
"autoload": {
"psr-4": {
diff --git a/vendor/brick/math/psalm-baseline.xml b/vendor/brick/math/psalm-baseline.xml
deleted file mode 100644
index fe05b998c..000000000
--- a/vendor/brick/math/psalm-baseline.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<files psalm-version="3.8.5@e6ec5fa22a7b9e61670a24d07b3119aff80dcd89">
- <file src="src/Internal/Calculator/BcMathCalculator.php">
- <InvalidNullableReturnType occurrences="3">
- <code>string</code>
- <code>string</code>
- <code>string</code>
- </InvalidNullableReturnType>
- <InvalidReturnStatement occurrences="1">
- <code>[$q, $r]</code>
- </InvalidReturnStatement>
- <InvalidReturnType occurrences="1">
- <code>array</code>
- </InvalidReturnType>
- <NullableReturnStatement occurrences="3">
- <code>\bcdiv($a, $b, 0)</code>
- <code>\bcmod($a, $b)</code>
- <code>\bcpowmod($base, $exp, $mod, 0)</code>
- </NullableReturnStatement>
- </file>
- <file src="src/Internal/Calculator/NativeCalculator.php">
- <InvalidOperand occurrences="6">
- <code>$a</code>
- <code>$a</code>
- <code>$a</code>
- <code>$b</code>
- <code>$blockA</code>
- <code>$blockA</code>
- </InvalidOperand>
- <LoopInvalidation occurrences="4">
- <code>$i</code>
- <code>$i</code>
- <code>$i</code>
- <code>$j</code>
- </LoopInvalidation>
- <PossiblyInvalidArgument occurrences="1">
- <code>$e / 2</code>
- </PossiblyInvalidArgument>
- </file>
-</files>
diff --git a/vendor/brick/math/psalm.xml b/vendor/brick/math/psalm.xml
deleted file mode 100644
index 123263ef4..000000000
--- a/vendor/brick/math/psalm.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0"?>
-<psalm
- totallyTyped="false"
- resolveFromConfigFile="true"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="https://getpsalm.org/schema/config"
- xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
- errorBaseline="psalm-baseline.xml"
->
- <projectFiles>
- <directory name="src" />
- <ignoreFiles>
- <directory name="vendor" />
- </ignoreFiles>
- </projectFiles>
-
- <issueHandlers>
- <LessSpecificReturnType errorLevel="info" />
-
- <!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->
-
- <DeprecatedMethod errorLevel="info" />
- <DeprecatedProperty errorLevel="info" />
- <DeprecatedClass errorLevel="info" />
- <DeprecatedConstant errorLevel="info" />
- <DeprecatedFunction errorLevel="info" />
- <DeprecatedInterface errorLevel="info" />
- <DeprecatedTrait errorLevel="info" />
-
- <InternalMethod errorLevel="info" />
- <InternalProperty errorLevel="info" />
- <InternalClass errorLevel="info" />
-
- <MissingClosureReturnType errorLevel="info" />
- <MissingReturnType errorLevel="info" />
- <MissingPropertyType errorLevel="info" />
- <InvalidDocblock errorLevel="info" />
- <MisplacedRequiredParam errorLevel="info" />
-
- <PropertyNotSetInConstructor errorLevel="info" />
- <MissingConstructor errorLevel="info" />
- <MissingClosureParamType errorLevel="info" />
- <MissingParamType errorLevel="info" />
-
- <RedundantCondition errorLevel="info" />
-
- <DocblockTypeContradiction errorLevel="info" />
- <RedundantConditionGivenDocblockType errorLevel="info" />
-
- <UnresolvableInclude errorLevel="info" />
-
- <RawObjectIteration errorLevel="info" />
-
- <InvalidStringClass errorLevel="info" />
- </issueHandlers>
-</psalm>
diff --git a/vendor/brick/math/random-tests.php b/vendor/brick/math/random-tests.php
index c59529f6f..d9053fc11 100644
--- a/vendor/brick/math/random-tests.php
+++ b/vendor/brick/math/random-tests.php
@@ -64,7 +64,7 @@ use Brick\Math\Internal\Calculator;
* @param string $a The left operand.
* @param string $b The right operand.
*/
- function runTests(string $a, string $b) : void
+ private function runTests(string $a, string $b) : void
{
$this->test("$a + $b", function(Calculator $c) use($a, $b) {
return $c->add($a, $b);
@@ -123,8 +123,11 @@ use Brick\Math\Internal\Calculator;
*/
private function test(string $test, Closure $callback) : void
{
- static $counter = 0;
- static $lastOutputTime = null;
+ static $testCounter = 0;
+ static $lastOutputTime = 0.0;
+ static $currentSecond = 0;
+ static $currentSecondTestCounter = 0;
+ static $testsPerSecond = 0;
$gmpResult = $callback($this->gmp);
$bcmathResult = $callback($this->bcmath);
@@ -138,13 +141,20 @@ use Brick\Math\Internal\Calculator;
self::failure('GMP', 'Native', $test);
}
- $counter++;
+ $testCounter++;
+ $currentSecondTestCounter++;
+
$time = microtime(true);
+ $second = (int) $time;
- if ($lastOutputTime === null) {
- $lastOutputTime = $time;
- } elseif ($time - $lastOutputTime >= 0.1) {
- echo "\r", number_format($counter);
+ 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;
}
}
diff --git a/vendor/brick/math/src/BigDecimal.php b/vendor/brick/math/src/BigDecimal.php
index 287177140..7707b166e 100644
--- a/vendor/brick/math/src/BigDecimal.php
+++ b/vendor/brick/math/src/BigDecimal.php
@@ -96,7 +96,10 @@ final class BigDecimal extends BigNumber
*/
public static function zero() : BigDecimal
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigDecimal|null $zero
+ */
static $zero;
if ($zero === null) {
@@ -115,7 +118,10 @@ final class BigDecimal extends BigNumber
*/
public static function one() : BigDecimal
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigDecimal|null $one
+ */
static $one;
if ($one === null) {
@@ -134,7 +140,10 @@ final class BigDecimal extends BigNumber
*/
public static function ten() : BigDecimal
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigDecimal|null $ten
+ */
static $ten;
if ($ten === null) {
@@ -677,11 +686,7 @@ final class BigDecimal extends BigNumber
*/
public function toBigInteger() : BigInteger
{
- if ($this->scale === 0) {
- $zeroScaleDecimal = $this;
- } else {
- $zeroScaleDecimal = $this->dividedBy(1, 0);
- }
+ $zeroScaleDecimal = $this->scale === 0 ? $this : $this->dividedBy(1, 0);
return BigInteger::create($zeroScaleDecimal->value);
}
@@ -763,6 +768,7 @@ final class BigDecimal extends BigNumber
* This method is only here to implement interface Serializable and cannot be accessed directly.
*
* @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
*
* @param string $value
*
diff --git a/vendor/brick/math/src/BigInteger.php b/vendor/brick/math/src/BigInteger.php
index cee3ce82b..0dcc8f3b3 100644
--- a/vendor/brick/math/src/BigInteger.php
+++ b/vendor/brick/math/src/BigInteger.php
@@ -217,6 +217,8 @@ final class BigInteger extends BigNumber
*
* Using the default random bytes generator, this method is suitable for cryptographic use.
*
+ * @psalm-param callable(int): string $randomBytesGenerator
+ *
* @param int $numBits The number of bits.
* @param callable|null $randomBytesGenerator A function that accepts a number of bytes as an integer, and returns a
* string of random bytes of the given length. Defaults to the
@@ -256,6 +258,8 @@ final class BigInteger extends BigNumber
*
* Using the default random bytes generator, this method is suitable for cryptographic use.
*
+ * @psalm-param (callable(int): string)|null $randomBytesGenerator
+ *
* @param BigNumber|int|float|string $min The lower bound. Must be convertible to a BigInteger.
* @param BigNumber|int|float|string $max The upper bound. Must be convertible to a BigInteger.
* @param callable|null $randomBytesGenerator A function that accepts a number of bytes as an integer,
@@ -300,7 +304,10 @@ final class BigInteger extends BigNumber
*/
public static function zero() : BigInteger
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigInteger|null $zero
+ */
static $zero;
if ($zero === null) {
@@ -319,7 +326,10 @@ final class BigInteger extends BigNumber
*/
public static function one() : BigInteger
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigInteger|null $one
+ */
static $one;
if ($one === null) {
@@ -338,7 +348,10 @@ final class BigInteger extends BigNumber
*/
public static function ten() : BigInteger
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigInteger|null $ten
+ */
static $ten;
if ($ten === null) {
@@ -1070,7 +1083,10 @@ final class BigInteger extends BigNumber
if ($signed) {
if ($this->isNegative()) {
- $hex = \bin2hex(~\hex2bin($hex));
+ $bin = \hex2bin($hex);
+ assert($bin !== false);
+
+ $hex = \bin2hex(~$bin);
$hex = self::fromBase($hex, 16)->plus(1)->toBase(16);
$hexLength = \strlen($hex);
@@ -1116,6 +1132,7 @@ final class BigInteger extends BigNumber
* This method is only here to implement interface Serializable and cannot be accessed directly.
*
* @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
*
* @param string $value
*
diff --git a/vendor/brick/math/src/BigNumber.php b/vendor/brick/math/src/BigNumber.php
index 59fcc7ce5..38c8c554e 100644
--- a/vendor/brick/math/src/BigNumber.php
+++ b/vendor/brick/math/src/BigNumber.php
@@ -67,13 +67,10 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
return new BigInteger((string) $value);
}
- if (\is_float($value)) {
- $value = self::floatToString($value);
- } else {
- $value = (string) $value;
- }
+ /** @psalm-suppress RedundantCastGivenDocblockType We cannot trust the untyped $value here! */
+ $value = \is_float($value) ? self::floatToString($value) : (string) $value;
- $throw = function() use ($value) : void {
+ $throw = static function() use ($value) : void {
throw new NumberFormatException(\sprintf(
'The given value "%s" does not represent a valid number.',
$value
@@ -84,7 +81,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
$throw();
}
- $getMatch = function(string $value) use ($matches) : ?string {
+ $getMatch = static function(string $value) use ($matches) : ?string {
return isset($matches[$value]) && $matches[$value] !== '' ? $matches[$value] : null;
};
@@ -93,7 +90,13 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
$denominator = $getMatch('denominator');
if ($numerator !== null) {
- $numerator = self::cleanUp($sign . $numerator);
+ assert($denominator !== null);
+
+ if ($sign !== null) {
+ $numerator = $sign . $numerator;
+ }
+
+ $numerator = self::cleanUp($numerator);
$denominator = self::cleanUp($denominator);
if ($denominator === '0') {
@@ -121,14 +124,14 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
}
if ($point !== null || $exponent !== null) {
- $fractional = $fractional ?? '';
- $exponent = $exponent !== null ? (int) $exponent : 0;
+ $fractional = ($fractional ?? '');
+ $exponent = ($exponent !== null) ? (int) $exponent : 0;
if ($exponent === PHP_INT_MIN || $exponent === PHP_INT_MAX) {
throw new NumberFormatException('Exponent too large.');
}
- $unscaledValue = self::cleanUp($sign . $integral . $fractional);
+ $unscaledValue = self::cleanUp(($sign ?? ''). $integral . $fractional);
$scale = \strlen($fractional) - $exponent;
@@ -142,7 +145,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
return new BigDecimal($unscaledValue, $scale);
}
- $integral = self::cleanUp($sign . $integral);
+ $integral = self::cleanUp(($sign ?? '') . $integral);
return new BigInteger($integral);
}
@@ -181,10 +184,11 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @return static
*
* @psalm-pure
+ * @psalm-suppress TooManyArguments
+ * @psalm-suppress UnsafeInstantiation
*/
protected static function create(... $args) : BigNumber
{
- /** @psalm-suppress TooManyArguments */
return new static(... $args);
}
@@ -199,6 +203,8 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @throws \InvalidArgumentException If no values are given.
* @throws MathException If an argument is not valid.
*
+ * @psalm-suppress LessSpecificReturnStatement
+ * @psalm-suppress MoreSpecificReturnType
* @psalm-pure
*/
public static function min(...$values) : BigNumber
@@ -231,6 +237,8 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @throws \InvalidArgumentException If no values are given.
* @throws MathException If an argument is not valid.
*
+ * @psalm-suppress LessSpecificReturnStatement
+ * @psalm-suppress MoreSpecificReturnType
* @psalm-pure
*/
public static function max(...$values) : BigNumber
@@ -263,6 +271,8 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @throws \InvalidArgumentException If no values are given.
* @throws MathException If an argument is not valid.
*
+ * @psalm-suppress LessSpecificReturnStatement
+ * @psalm-suppress MoreSpecificReturnType
* @psalm-pure
*/
public static function sum(...$values) : BigNumber
@@ -273,11 +283,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
foreach ($values as $value) {
$value = static::of($value);
- if ($sum === null) {
- $sum = $value;
- } else {
- $sum = self::add($sum, $value);
- }
+ $sum = $sum === null ? $value : self::add($sum, $value);
}
if ($sum === null) {
diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php
index ff035c5c0..7fbabd7f1 100644
--- a/vendor/brick/math/src/BigRational.php
+++ b/vendor/brick/math/src/BigRational.php
@@ -108,7 +108,10 @@ final class BigRational extends BigNumber
*/
public static function zero() : BigRational
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigRational|null $zero
+ */
static $zero;
if ($zero === null) {
@@ -127,7 +130,10 @@ final class BigRational extends BigNumber
*/
public static function one() : BigRational
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigRational|null $one
+ */
static $one;
if ($one === null) {
@@ -146,7 +152,10 @@ final class BigRational extends BigNumber
*/
public static function ten() : BigRational
{
- /** @psalm-suppress ImpureStaticVariable */
+ /**
+ * @psalm-suppress ImpureStaticVariable
+ * @var BigRational|null $ten
+ */
static $ten;
if ($ten === null) {
@@ -458,6 +467,7 @@ final class BigRational extends BigNumber
* This method is only here to implement interface Serializable and cannot be accessed directly.
*
* @internal
+ * @psalm-suppress RedundantPropertyInitializationCheck
*
* @param string $value
*
diff --git a/vendor/brick/math/src/Internal/Calculator.php b/vendor/brick/math/src/Internal/Calculator.php
index 44795acbb..99b478193 100644
--- a/vendor/brick/math/src/Internal/Calculator.php
+++ b/vendor/brick/math/src/Internal/Calculator.php
@@ -677,6 +677,9 @@ abstract class Calculator
}
/**
+ * @psalm-suppress InvalidOperand
+ * @see https://github.com/vimeo/psalm/issues/4456
+ *
* @param string $number A positive, binary number.
*
* @return string
@@ -685,7 +688,7 @@ abstract class Calculator
{
$xor = \str_repeat("\xff", \strlen($number));
- $number = $number ^ $xor;
+ $number ^= $xor;
for ($i = \strlen($number) - 1; $i >= 0; $i--) {
$byte = \ord($number[$i]);
diff --git a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
index c087245bd..6632b378a 100644
--- a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
@@ -41,6 +41,9 @@ class BcMathCalculator extends Calculator
/**
* {@inheritdoc}
+ *
+ * @psalm-suppress InvalidNullableReturnType
+ * @psalm-suppress NullableReturnStatement
*/
public function divQ(string $a, string $b) : string
{
@@ -49,9 +52,16 @@ class BcMathCalculator extends Calculator
/**
* {@inheritdoc}
+ *
+ * @psalm-suppress InvalidNullableReturnType
+ * @psalm-suppress NullableReturnStatement
*/
public function divR(string $a, string $b) : string
{
+ if (version_compare(PHP_VERSION, '7.2') >= 0) {
+ return \bcmod($a, $b, 0);
+ }
+
return \bcmod($a, $b);
}
@@ -61,7 +71,15 @@ class BcMathCalculator extends Calculator
public function divQR(string $a, string $b) : array
{
$q = \bcdiv($a, $b, 0);
- $r = \bcmod($a, $b);
+
+ if (version_compare(PHP_VERSION, '7.2') >= 0) {
+ $r = \bcmod($a, $b, 0);
+ } else {
+ $r = \bcmod($a, $b);
+ }
+
+ assert($q !== null);
+ assert($r !== null);
return [$q, $r];
}
@@ -76,6 +94,9 @@ class BcMathCalculator extends Calculator
/**
* {@inheritdoc}
+ *
+ * @psalm-suppress InvalidNullableReturnType
+ * @psalm-suppress NullableReturnStatement
*/
public function modPow(string $base, string $exp, string $mod) : string
{
@@ -84,6 +105,9 @@ 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 d248e6849..a5f8a9b48 100644
--- a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
@@ -53,6 +53,10 @@ class NativeCalculator extends Calculator
*/
public function add(string $a, string $b) : string
{
+ /**
+ * @psalm-var numeric-string $a
+ * @psalm-var numeric-string $b
+ */
$result = $a + $b;
if (is_int($result)) {
@@ -69,11 +73,7 @@ class NativeCalculator extends Calculator
[$aNeg, $bNeg, $aDig, $bDig] = $this->init($a, $b);
- if ($aNeg === $bNeg) {
- $result = $this->doAdd($aDig, $bDig);
- } else {
- $result = $this->doSub($aDig, $bDig);
- }
+ $result = $aNeg === $bNeg ? $this->doAdd($aDig, $bDig) : $this->doSub($aDig, $bDig);
if ($aNeg) {
$result = $this->neg($result);
@@ -95,6 +95,10 @@ class NativeCalculator extends Calculator
*/
public function mul(string $a, string $b) : string
{
+ /**
+ * @psalm-var numeric-string $a
+ * @psalm-var numeric-string $b
+ */
$result = $a * $b;
if (is_int($result)) {
@@ -169,9 +173,11 @@ class NativeCalculator extends Calculator
return [$this->neg($a), '0'];
}
+ /** @psalm-var numeric-string $a */
$na = $a * 1; // cast to number
if (is_int($na)) {
+ /** @psalm-var numeric-string $b */
$nb = $b * 1;
if (is_int($nb)) {
@@ -221,6 +227,8 @@ class NativeCalculator extends Calculator
$e -= $odd;
$aa = $this->mul($a, $a);
+
+ /** @psalm-suppress PossiblyInvalidArgument We're sure that $e / 2 is an int now */
$result = $this->pow($aa, $e / 2);
if ($odd === 1) {
@@ -316,10 +324,14 @@ class NativeCalculator extends Calculator
if ($i < 0) {
$blockLength += $i;
+ /** @psalm-suppress LoopInvalidation */
$i = 0;
}
+ /** @psalm-var numeric-string $blockA */
$blockA = \substr($a, $i, $blockLength);
+
+ /** @psalm-var numeric-string $blockB */
$blockB = \substr($b, $i, $blockLength);
$sum = (string) ($blockA + $blockB + $carry);
@@ -386,10 +398,14 @@ class NativeCalculator extends Calculator
if ($i < 0) {
$blockLength += $i;
+ /** @psalm-suppress LoopInvalidation */
$i = 0;
}
+ /** @psalm-var numeric-string $blockA */
$blockA = \substr($a, $i, $blockLength);
+
+ /** @psalm-var numeric-string $blockB */
$blockB = \substr($b, $i, $blockLength);
$sum = $blockA - $blockB - $carry;
@@ -450,6 +466,7 @@ class NativeCalculator extends Calculator
if ($i < 0) {
$blockALength += $i;
+ /** @psalm-suppress LoopInvalidation */
$i = 0;
}
@@ -463,6 +480,7 @@ class NativeCalculator extends Calculator
if ($j < 0) {
$blockBLength += $j;
+ /** @psalm-suppress LoopInvalidation */
$j = 0;
}