aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-05-30 08:36:17 +0000
committerMario <mario@mariovavti.com>2023-05-30 08:36:17 +0000
commitb9812ba06ac16899df2a25f0abf25962ae3273f2 (patch)
tree35762d0183f5b0c6d866b00cdeebfbae595cfa56 /vendor/brick
parentbc6aded074156ec81084334a4d6aa58bc0f37a68 (diff)
downloadvolse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.tar.gz
volse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.tar.bz2
volse-hubzilla-b9812ba06ac16899df2a25f0abf25962ae3273f2.zip
update composer libs
Diffstat (limited to 'vendor/brick')
-rw-r--r--vendor/brick/math/CHANGELOG.md40
-rw-r--r--vendor/brick/math/SECURITY.md17
-rw-r--r--vendor/brick/math/composer.json7
-rw-r--r--vendor/brick/math/src/BigDecimal.php145
-rw-r--r--vendor/brick/math/src/BigInteger.php183
-rw-r--r--vendor/brick/math/src/BigNumber.php132
-rw-r--r--vendor/brick/math/src/BigRational.php106
-rw-r--r--vendor/brick/math/src/Exception/DivisionByZeroException.php6
-rw-r--r--vendor/brick/math/src/Exception/IntegerOverflowException.php4
-rw-r--r--vendor/brick/math/src/Exception/MathException.php4
-rw-r--r--vendor/brick/math/src/Exception/NumberFormatException.php2
-rw-r--r--vendor/brick/math/src/Exception/RoundingNecessaryException.php2
-rw-r--r--vendor/brick/math/src/Internal/Calculator.php110
-rw-r--r--vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php47
-rw-r--r--vendor/brick/math/src/Internal/Calculator/GmpCalculator.php48
-rw-r--r--vendor/brick/math/src/Internal/Calculator/NativeCalculator.php57
16 files changed, 166 insertions, 744 deletions
diff --git a/vendor/brick/math/CHANGELOG.md b/vendor/brick/math/CHANGELOG.md
index 03c3d824d..17cea8d9f 100644
--- a/vendor/brick/math/CHANGELOG.md
+++ b/vendor/brick/math/CHANGELOG.md
@@ -2,11 +2,41 @@
All notable changes to this project will be documented in this file.
+## [0.11.0](https://github.com/brick/math/releases/tag/0.11.0) - 2023-01-16
+
+💥 **Breaking changes**
+
+- Minimum PHP version is now 8.0
+- Methods accepting a union of types are now strongly typed<sup>*</sup>
+- `MathException` now extends `Exception` instead of `RuntimeException`
+
+<sup>* You may now run into type errors if you were passing `Stringable` objects to `of()` or any of the methods
+internally calling `of()`, with `strict_types` enabled. You can fix this by casting `Stringable` objects to `string`
+first.</sup>
+
+## [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 +46,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
@@ -325,8 +355,8 @@ This release also comes with many performance improvements.
- `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
+ - `toBigInteger()` does not accept a `$roundingMode` parameter anymore
+ - `toBigRational()` does not simplify the fraction anymore; explicitly add `->simplified()` to get the previous behaviour
- `BigRational`:
- `getSign()` is renamed to `sign()`
- `getNumerator()` is renamed to `numerator()`
@@ -400,7 +430,7 @@ 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
+- `min()` and `max()` do not accept an `array` anymore, but a variable number of parameters
- **minimum PHP version is now 5.6**
- continuous integration with PHP 7
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..ed817bdd0 100644
--- a/vendor/brick/math/composer.json
+++ b/vendor/brick/math/composer.json
@@ -14,13 +14,12 @@
],
"license": "MIT",
"require": {
- "php": "^7.1 || ^8.0",
- "ext-json": "*"
+ "php": "^8.0"
},
"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": "5.0.0"
},
"autoload": {
"psr-4": {
diff --git a/vendor/brick/math/src/BigDecimal.php b/vendor/brick/math/src/BigDecimal.php
index 78246500c..02fc65612 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.
@@ -51,15 +47,11 @@ final class BigDecimal extends BigNumber
/**
* Creates a BigDecimal of the given value.
*
- * @param BigNumber|int|float|string $value
- *
- * @return BigDecimal
- *
* @throws MathException If the value cannot be converted to a BigDecimal.
*
* @psalm-pure
*/
- public static function of($value) : BigNumber
+ public static function of(BigNumber|int|float|string $value) : BigDecimal
{
return parent::of($value)->toBigDecimal();
}
@@ -72,13 +64,11 @@ final class BigDecimal extends BigNumber
* @param BigNumber|int|float|string $value The unscaled value. Must be convertible to a BigInteger.
* @param int $scale The scale of the number, positive or zero.
*
- * @return BigDecimal
- *
* @throws \InvalidArgumentException If the scale is negative.
*
* @psalm-pure
*/
- public static function ofUnscaledValue($value, int $scale = 0) : BigDecimal
+ public static function ofUnscaledValue(BigNumber|int|float|string $value, int $scale = 0) : BigDecimal
{
if ($scale < 0) {
throw new \InvalidArgumentException('The scale cannot be negative.');
@@ -90,8 +80,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a BigDecimal representing zero, with a scale of zero.
*
- * @return BigDecimal
- *
* @psalm-pure
*/
public static function zero() : BigDecimal
@@ -112,8 +100,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a BigDecimal representing one, with a scale of zero.
*
- * @return BigDecimal
- *
* @psalm-pure
*/
public static function one() : BigDecimal
@@ -134,8 +120,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a BigDecimal representing ten, with a scale of zero.
*
- * @return BigDecimal
- *
* @psalm-pure
*/
public static function ten() : BigDecimal
@@ -160,11 +144,9 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The number to add. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The result.
- *
* @throws MathException If the number is not valid, or is not convertible to a BigDecimal.
*/
- public function plus($that) : BigDecimal
+ public function plus(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -191,11 +173,9 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The result.
- *
* @throws MathException If the number is not valid, or is not convertible to a BigDecimal.
*/
- public function minus($that) : BigDecimal
+ public function minus(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -218,11 +198,9 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The multiplier. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The result.
- *
* @throws MathException If the multiplier is not a valid number, or is not convertible to a BigDecimal.
*/
- public function multipliedBy($that) : BigDecimal
+ public function multipliedBy(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -247,12 +225,10 @@ final class BigDecimal extends BigNumber
* @param int|null $scale The desired scale, or null to use the scale of this number.
* @param int $roundingMode An optional rounding mode.
*
- * @return BigDecimal
- *
* @throws \InvalidArgumentException If the scale or rounding mode is invalid.
* @throws MathException If the number is invalid, is zero, or rounding was necessary.
*/
- public function dividedBy($that, ?int $scale = null, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal
+ public function dividedBy(BigNumber|int|float|string $that, ?int $scale = null, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -285,12 +261,10 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The result.
- *
* @throws MathException If the divisor is not a valid number, is not convertible to a BigDecimal, is zero,
* or the result yields an infinite number of digits.
*/
- public function exactlyDividedBy($that) : BigDecimal
+ public function exactlyDividedBy(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -326,10 +300,6 @@ final class BigDecimal extends BigNumber
*
* The result has a scale of `$this->scale * $exponent`.
*
- * @param int $exponent The exponent.
- *
- * @return BigDecimal The result.
- *
* @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000.
*/
public function power(int $exponent) : BigDecimal
@@ -360,11 +330,9 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The quotient.
- *
* @throws MathException If the divisor is not a valid decimal number, or is zero.
*/
- public function quotient($that) : BigDecimal
+ public function quotient(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -387,11 +355,9 @@ final class BigDecimal extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.
*
- * @return BigDecimal The remainder.
- *
* @throws MathException If the divisor is not a valid decimal number, or is zero.
*/
- public function remainder($that) : BigDecimal
+ public function remainder(BigNumber|int|float|string $that) : BigDecimal
{
$that = BigDecimal::of($that);
@@ -420,7 +386,7 @@ final class BigDecimal extends BigNumber
*
* @throws MathException If the divisor is not a valid decimal number, or is zero.
*/
- public function quotientAndRemainder($that) : array
+ public function quotientAndRemainder(BigNumber|int|float|string $that) : array
{
$that = BigDecimal::of($that);
@@ -444,10 +410,6 @@ final class BigDecimal extends BigNumber
/**
* Returns the square root of this number, rounded down to the given number of decimals.
*
- * @param int $scale
- *
- * @return BigDecimal
- *
* @throws \InvalidArgumentException If the scale is negative.
* @throws NegativeNumberException If this number is negative.
*/
@@ -488,10 +450,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a copy of this BigDecimal with the decimal point moved $n places to the left.
- *
- * @param int $n
- *
- * @return BigDecimal
*/
public function withPointMovedLeft(int $n) : BigDecimal
{
@@ -508,10 +466,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a copy of this BigDecimal with the decimal point moved $n places to the right.
- *
- * @param int $n
- *
- * @return BigDecimal
*/
public function withPointMovedRight(int $n) : BigDecimal
{
@@ -538,8 +492,6 @@ final class BigDecimal extends BigNumber
/**
* Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part.
- *
- * @return BigDecimal
*/
public function stripTrailingZeros() : BigDecimal
{
@@ -571,8 +523,6 @@ final class BigDecimal extends BigNumber
/**
* Returns the absolute value of this number.
- *
- * @return BigDecimal
*/
public function abs() : BigDecimal
{
@@ -581,18 +531,13 @@ final class BigDecimal extends BigNumber
/**
* Returns the negated value of this number.
- *
- * @return BigDecimal
*/
public function negated() : BigDecimal
{
return new BigDecimal(Calculator::get()->neg($this->value), $this->scale);
}
- /**
- * {@inheritdoc}
- */
- public function compareTo($that) : int
+ public function compareTo(BigNumber|int|float|string $that) : int
{
$that = BigNumber::of($that);
@@ -609,25 +554,16 @@ final class BigDecimal extends BigNumber
return - $that->compareTo($this);
}
- /**
- * {@inheritdoc}
- */
public function getSign() : int
{
return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1);
}
- /**
- * @return BigInteger
- */
public function getUnscaledValue() : BigInteger
{
- return BigInteger::create($this->value);
+ return self::newBigInteger($this->value);
}
- /**
- * @return int
- */
public function getScale() : int
{
return $this->scale;
@@ -637,8 +573,6 @@ final class BigDecimal extends BigNumber
* Returns a string representing the integral part of this decimal number.
*
* Example: `-123.456` => `-123`.
- *
- * @return string
*/
public function getIntegralPart() : string
{
@@ -657,8 +591,6 @@ final class BigDecimal extends BigNumber
* If the scale is zero, an empty string is returned.
*
* Examples: `-123.456` => '456', `123` => ''.
- *
- * @return string
*/
public function getFractionalPart() : string
{
@@ -673,46 +605,32 @@ final class BigDecimal extends BigNumber
/**
* Returns whether this decimal number has a non-zero fractional part.
- *
- * @return bool
*/
public function hasNonZeroFractionalPart() : bool
{
return $this->getFractionalPart() !== \str_repeat('0', $this->scale);
}
- /**
- * {@inheritdoc}
- */
public function toBigInteger() : BigInteger
{
$zeroScaleDecimal = $this->scale === 0 ? $this : $this->dividedBy(1, 0);
- return BigInteger::create($zeroScaleDecimal->value);
+ return self::newBigInteger($zeroScaleDecimal->value);
}
- /**
- * {@inheritdoc}
- */
public function toBigDecimal() : BigDecimal
{
return $this;
}
- /**
- * {@inheritdoc}
- */
public function toBigRational() : BigRational
{
- $numerator = BigInteger::create($this->value);
- $denominator = BigInteger::create('1' . \str_repeat('0', $this->scale));
+ $numerator = self::newBigInteger($this->value);
+ $denominator = self::newBigInteger('1' . \str_repeat('0', $this->scale));
- return BigRational::create($numerator, $denominator, false);
+ return self::newBigRational($numerator, $denominator, false);
}
- /**
- * {@inheritdoc}
- */
public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal
{
if ($scale === $this->scale) {
@@ -722,25 +640,16 @@ final class BigDecimal extends BigNumber
return $this->dividedBy(BigDecimal::one(), $scale, $roundingMode);
}
- /**
- * {@inheritdoc}
- */
public function toInt() : int
{
return $this->toBigInteger()->toInt();
}
- /**
- * {@inheritdoc}
- */
public function toFloat() : float
{
return (float) (string) $this;
}
- /**
- * {@inheritdoc}
- */
public function __toString() : string
{
if ($this->scale === 0) {
@@ -772,8 +681,6 @@ final class BigDecimal extends BigNumber
*
* @param array{value: string, scale: int} $data
*
- * @return void
- *
* @throws \LogicException
*/
public function __unserialize(array $data): void
@@ -790,8 +697,6 @@ final class BigDecimal extends BigNumber
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
- *
- * @return string
*/
public function serialize() : string
{
@@ -804,10 +709,6 @@ final class BigDecimal extends BigNumber
* @internal
* @psalm-suppress RedundantPropertyInitializationCheck
*
- * @param string $value
- *
- * @return void
- *
* @throws \LogicException
*/
public function unserialize($value) : void
@@ -825,9 +726,6 @@ final class BigDecimal extends BigNumber
/**
* Puts the internal values of the given decimal numbers on the same scale.
*
- * @param BigDecimal $x The first decimal number.
- * @param BigDecimal $y The second decimal number.
- *
* @return array{string, string} The scaled integer values of $x and $y.
*/
private function scaleValues(BigDecimal $x, BigDecimal $y) : array
@@ -844,11 +742,6 @@ final class BigDecimal extends BigNumber
return [$a, $b];
}
- /**
- * @param int $scale
- *
- * @return string
- */
private function valueWithMinScale(int $scale) : string
{
$value = $this->value;
@@ -862,8 +755,6 @@ final class BigDecimal extends BigNumber
/**
* Adds leading zeros if necessary to the unscaled value to represent the full decimal number.
- *
- * @return string
*/
private function getUnscaledValueWithLeadingZeros() : string
{
diff --git a/vendor/brick/math/src/BigInteger.php b/vendor/brick/math/src/BigInteger.php
index f213fbedb..435679331 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.
@@ -44,15 +42,11 @@ final class BigInteger extends BigNumber
/**
* Creates a BigInteger of the given value.
*
- * @param BigNumber|int|float|string $value
- *
- * @return BigInteger
- *
* @throws MathException If the value cannot be converted to a BigInteger.
*
* @psalm-pure
*/
- public static function of($value) : BigNumber
+ public static function of(BigNumber|int|float|string $value) : BigInteger
{
return parent::of($value)->toBigInteger();
}
@@ -71,8 +65,6 @@ final class BigInteger extends BigNumber
* @param string $number The number to convert, in the given base.
* @param int $base The base of the number, between 2 and 36.
*
- * @return BigInteger
- *
* @throws NumberFormatException If the number is empty, or contains invalid chars for the given base.
* @throws \InvalidArgumentException If the base is out of range.
*
@@ -138,8 +130,6 @@ final class BigInteger extends BigNumber
* @param string $number The number to parse.
* @param string $alphabet The alphabet, for example '01' for base 2, or '01234567' for base 8.
*
- * @return BigInteger
- *
* @throws NumberFormatException If the given number is empty or contains invalid chars for the given alphabet.
* @throws \InvalidArgumentException If the alphabet does not contain at least 2 chars.
*
@@ -183,8 +173,6 @@ final class BigInteger extends BigNumber
* @param bool $signed Whether to interpret as a signed number in two's-complement representation with a leading
* sign bit.
*
- * @return BigInteger
- *
* @throws NumberFormatException If the string is empty.
*/
public static function fromBytes(string $value, bool $signed = true) : BigInteger
@@ -217,15 +205,13 @@ final class BigInteger extends BigNumber
*
* Using the default random bytes generator, this method is suitable for cryptographic use.
*
- * @psalm-param callable(int): string $randomBytesGenerator
+ * @psalm-param (callable(int): string)|null $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
* `random_bytes()` function.
*
- * @return BigInteger
- *
* @throws \InvalidArgumentException If $numBits is negative.
*/
public static function randomBits(int $numBits, ?callable $randomBytesGenerator = null) : BigInteger
@@ -266,13 +252,14 @@ final class BigInteger extends BigNumber
* and returns a string of random bytes of the given length.
* Defaults to the `random_bytes()` function.
*
- * @return BigInteger
- *
* @throws MathException If one of the parameters cannot be converted to a BigInteger,
* or `$min` is greater than `$max`.
*/
- public static function randomRange($min, $max, ?callable $randomBytesGenerator = null) : BigInteger
- {
+ public static function randomRange(
+ BigNumber|int|float|string $min,
+ BigNumber|int|float|string $max,
+ ?callable $randomBytesGenerator = null
+ ) : BigInteger {
$min = BigInteger::of($min);
$max = BigInteger::of($max);
@@ -298,8 +285,6 @@ final class BigInteger extends BigNumber
/**
* Returns a BigInteger representing zero.
*
- * @return BigInteger
- *
* @psalm-pure
*/
public static function zero() : BigInteger
@@ -320,8 +305,6 @@ final class BigInteger extends BigNumber
/**
* Returns a BigInteger representing one.
*
- * @return BigInteger
- *
* @psalm-pure
*/
public static function one() : BigInteger
@@ -342,8 +325,6 @@ final class BigInteger extends BigNumber
/**
* Returns a BigInteger representing ten.
*
- * @return BigInteger
- *
* @psalm-pure
*/
public static function ten() : BigInteger
@@ -361,16 +342,29 @@ 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.
*
* @param BigNumber|int|float|string $that The number to add. Must be convertible to a BigInteger.
*
- * @return BigInteger The result.
- *
* @throws MathException If the number is not valid, or is not convertible to a BigInteger.
*/
- public function plus($that) : BigInteger
+ public function plus(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -392,11 +386,9 @@ final class BigInteger extends BigNumber
*
* @param BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigInteger.
*
- * @return BigInteger The result.
- *
* @throws MathException If the number is not valid, or is not convertible to a BigInteger.
*/
- public function minus($that) : BigInteger
+ public function minus(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -414,11 +406,9 @@ final class BigInteger extends BigNumber
*
* @param BigNumber|int|float|string $that The multiplier. Must be convertible to a BigInteger.
*
- * @return BigInteger The result.
- *
* @throws MathException If the multiplier is not a valid number, or is not convertible to a BigInteger.
*/
- public function multipliedBy($that) : BigInteger
+ public function multipliedBy(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -441,12 +431,10 @@ final class BigInteger extends BigNumber
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger.
* @param int $roundingMode An optional rounding mode.
*
- * @return BigInteger The result.
- *
* @throws MathException If the divisor is not a valid number, is not convertible to a BigInteger, is zero,
* or RoundingMode::UNNECESSARY is used and the remainder is not zero.
*/
- public function dividedBy($that, int $roundingMode = RoundingMode::UNNECESSARY) : BigInteger
+ public function dividedBy(BigNumber|int|float|string $that, int $roundingMode = RoundingMode::UNNECESSARY) : BigInteger
{
$that = BigInteger::of($that);
@@ -466,10 +454,6 @@ final class BigInteger extends BigNumber
/**
* Returns this number exponentiated to the given value.
*
- * @param int $exponent The exponent.
- *
- * @return BigInteger The result.
- *
* @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000.
*/
public function power(int $exponent) : BigInteger
@@ -498,11 +482,9 @@ final class BigInteger extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger.
*
- * @return BigInteger
- *
* @throws DivisionByZeroException If the divisor is zero.
*/
- public function quotient($that) : BigInteger
+ public function quotient(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -526,11 +508,9 @@ final class BigInteger extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger.
*
- * @return BigInteger
- *
* @throws DivisionByZeroException If the divisor is zero.
*/
- public function remainder($that) : BigInteger
+ public function remainder(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -556,7 +536,7 @@ final class BigInteger extends BigNumber
*
* @throws DivisionByZeroException If the divisor is zero.
*/
- public function quotientAndRemainder($that) : array
+ public function quotientAndRemainder(BigNumber|int|float|string $that) : array
{
$that = BigInteger::of($that);
@@ -582,11 +562,9 @@ final class BigInteger extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor. Must be convertible to a BigInteger.
*
- * @return BigInteger
- *
* @throws DivisionByZeroException If the divisor is zero.
*/
- public function mod($that) : BigInteger
+ public function mod(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -602,10 +580,6 @@ final class BigInteger extends BigNumber
/**
* Returns the modular multiplicative inverse of this BigInteger modulo $m.
*
- * @param BigInteger $m
- *
- * @return BigInteger
- *
* @throws DivisionByZeroException If $m is zero.
* @throws NegativeNumberException If $m is negative.
* @throws MathException If this BigInteger has no multiplicative inverse mod m (that is, this BigInteger
@@ -642,12 +616,10 @@ final class BigInteger extends BigNumber
* @param BigNumber|int|float|string $exp The exponent. Must be positive or zero.
* @param BigNumber|int|float|string $mod The modulus. Must be strictly positive.
*
- * @return BigInteger
- *
* @throws NegativeNumberException If any of the operands is negative.
* @throws DivisionByZeroException If the modulus is zero.
*/
- public function modPow($exp, $mod) : BigInteger
+ public function modPow(BigNumber|int|float|string $exp, BigNumber|int|float|string $mod) : BigInteger
{
$exp = BigInteger::of($exp);
$mod = BigInteger::of($mod);
@@ -671,10 +643,8 @@ final class BigInteger extends BigNumber
* The GCD is always positive, unless both operands are zero, in which case it is zero.
*
* @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number.
- *
- * @return BigInteger
*/
- public function gcd($that) : BigInteger
+ public function gcd(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -696,8 +666,6 @@ final class BigInteger extends BigNumber
*
* The result is the largest x such that x² ≤ n.
*
- * @return BigInteger
- *
* @throws NegativeNumberException If this number is negative.
*/
public function sqrt() : BigInteger
@@ -713,8 +681,6 @@ final class BigInteger extends BigNumber
/**
* Returns the absolute value of this number.
- *
- * @return BigInteger
*/
public function abs() : BigInteger
{
@@ -723,8 +689,6 @@ final class BigInteger extends BigNumber
/**
* Returns the inverse of this number.
- *
- * @return BigInteger
*/
public function negated() : BigInteger
{
@@ -737,10 +701,8 @@ final class BigInteger extends BigNumber
* This method returns a negative BigInteger if and only if both operands are negative.
*
* @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number.
- *
- * @return BigInteger
*/
- public function and($that) : BigInteger
+ public function and(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -753,10 +715,8 @@ final class BigInteger extends BigNumber
* This method returns a negative BigInteger if and only if either of the operands is negative.
*
* @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number.
- *
- * @return BigInteger
*/
- public function or($that) : BigInteger
+ public function or(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -769,10 +729,8 @@ final class BigInteger extends BigNumber
* This method returns a negative BigInteger if and only if exactly one of the operands is negative.
*
* @param BigNumber|int|float|string $that The operand. Must be convertible to an integer number.
- *
- * @return BigInteger
*/
- public function xor($that) : BigInteger
+ public function xor(BigNumber|int|float|string $that) : BigInteger
{
$that = BigInteger::of($that);
@@ -781,8 +739,6 @@ final class BigInteger extends BigNumber
/**
* Returns the bitwise-not of this BigInteger.
- *
- * @return BigInteger
*/
public function not() : BigInteger
{
@@ -791,10 +747,6 @@ final class BigInteger extends BigNumber
/**
* Returns the integer left shifted by a given number of bits.
- *
- * @param int $distance The distance to shift.
- *
- * @return BigInteger
*/
public function shiftedLeft(int $distance) : BigInteger
{
@@ -811,10 +763,6 @@ final class BigInteger extends BigNumber
/**
* Returns the integer right shifted by a given number of bits.
- *
- * @param int $distance The distance to shift.
- *
- * @return BigInteger
*/
public function shiftedRight(int $distance) : BigInteger
{
@@ -840,8 +788,6 @@ final class BigInteger extends BigNumber
*
* For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation.
* Computes (ceil(log2(this < 0 ? -this : this+1))).
- *
- * @return int
*/
public function getBitLength() : int
{
@@ -860,8 +806,6 @@ final class BigInteger extends BigNumber
* Returns the index of the rightmost (lowest-order) one bit in this BigInteger.
*
* Returns -1 if this BigInteger contains no one bits.
- *
- * @return int
*/
public function getLowestSetBit() : int
{
@@ -881,8 +825,6 @@ final class BigInteger extends BigNumber
/**
* Returns whether this number is even.
- *
- * @return bool
*/
public function isEven() : bool
{
@@ -891,8 +833,6 @@ final class BigInteger extends BigNumber
/**
* Returns whether this number is odd.
- *
- * @return bool
*/
public function isOdd() : bool
{
@@ -906,8 +846,6 @@ final class BigInteger extends BigNumber
*
* @param int $n The bit to test, 0-based.
*
- * @return bool
- *
* @throws \InvalidArgumentException If the bit to test is negative.
*/
public function testBit(int $n) : bool
@@ -919,10 +857,7 @@ final class BigInteger extends BigNumber
return $this->shiftedRight($n)->isOdd();
}
- /**
- * {@inheritdoc}
- */
- public function compareTo($that) : int
+ public function compareTo(BigNumber|int|float|string $that) : int
{
$that = BigNumber::of($that);
@@ -933,49 +868,31 @@ final class BigInteger extends BigNumber
return - $that->compareTo($this);
}
- /**
- * {@inheritdoc}
- */
public function getSign() : int
{
return ($this->value === '0') ? 0 : (($this->value[0] === '-') ? -1 : 1);
}
- /**
- * {@inheritdoc}
- */
public function toBigInteger() : BigInteger
{
return $this;
}
- /**
- * {@inheritdoc}
- */
public function toBigDecimal() : BigDecimal
{
- return BigDecimal::create($this->value);
+ return self::newBigDecimal($this->value);
}
- /**
- * {@inheritdoc}
- */
public function toBigRational() : BigRational
{
- return BigRational::create($this, BigInteger::one(), false);
+ return self::newBigRational($this, BigInteger::one(), false);
}
- /**
- * {@inheritdoc}
- */
public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal
{
return $this->toBigDecimal()->toScale($scale, $roundingMode);
}
- /**
- * {@inheritdoc}
- */
public function toInt() : int
{
$intValue = (int) $this->value;
@@ -987,9 +904,6 @@ final class BigInteger extends BigNumber
return $intValue;
}
- /**
- * {@inheritdoc}
- */
public function toFloat() : float
{
return (float) $this->value;
@@ -1000,10 +914,6 @@ final class BigInteger extends BigNumber
*
* The output will always be lowercase for bases greater than 10.
*
- * @param int $base
- *
- * @return string
- *
* @throws \InvalidArgumentException If the base is out of range.
*/
public function toBase(int $base) : string
@@ -1027,8 +937,6 @@ final class BigInteger extends BigNumber
*
* @param string $alphabet The alphabet, for example '01' for base 2, or '01234567' for base 8.
*
- * @return string
- *
* @throws NegativeNumberException If this number is negative.
* @throws \InvalidArgumentException If the given alphabet does not contain at least 2 chars.
*/
@@ -1063,8 +971,6 @@ final class BigInteger extends BigNumber
*
* @param bool $signed Whether to output a signed number in two's-complement representation with a leading sign bit.
*
- * @return string
- *
* @throws NegativeNumberException If $signed is false, and the number is negative.
*/
public function toBytes(bool $signed = true) : string
@@ -1108,9 +1014,6 @@ final class BigInteger extends BigNumber
return \hex2bin($hex);
}
- /**
- * {@inheritdoc}
- */
public function __toString() : string
{
return $this->value;
@@ -1136,8 +1039,6 @@ final class BigInteger extends BigNumber
*
* @param array{value: string} $data
*
- * @return void
- *
* @throws \LogicException
*/
public function __unserialize(array $data): void
@@ -1153,8 +1054,6 @@ final class BigInteger extends BigNumber
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
- *
- * @return string
*/
public function serialize() : string
{
@@ -1167,10 +1066,6 @@ final class BigInteger extends BigNumber
* @internal
* @psalm-suppress RedundantPropertyInitializationCheck
*
- * @param string $value
- *
- * @return void
- *
* @throws \LogicException
*/
public function unserialize($value) : void
diff --git a/vendor/brick/math/src/BigNumber.php b/vendor/brick/math/src/BigNumber.php
index 38c8c554e..80146d207 100644
--- a/vendor/brick/math/src/BigNumber.php
+++ b/vendor/brick/math/src/BigNumber.php
@@ -48,16 +48,12 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* - strings containing a `.` character or using an exponential notation are returned as BigDecimal
* - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger
*
- * @param BigNumber|int|float|string $value
- *
- * @return BigNumber
- *
* @throws NumberFormatException If the format of the number is not valid.
* @throws DivisionByZeroException If the value represents a rational number with a denominator of zero.
*
* @psalm-pure
*/
- public static function of($value) : BigNumber
+ public static function of(BigNumber|int|float|string $value) : BigNumber
{
if ($value instanceof BigNumber) {
return $value;
@@ -67,8 +63,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
return new BigInteger((string) $value);
}
- /** @psalm-suppress RedundantCastGivenDocblockType We cannot trust the untyped $value here! */
- $value = \is_float($value) ? self::floatToString($value) : (string) $value;
+ $value = \is_float($value) ? self::floatToString($value) : $value;
$throw = static function() use ($value) : void {
throw new NumberFormatException(\sprintf(
@@ -81,9 +76,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');
@@ -155,10 +148,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
*
* @see https://github.com/brick/math/pull/20
*
- * @param float $float
- *
- * @return string
- *
* @psalm-pure
* @psalm-suppress ImpureFunctionCall
*/
@@ -175,21 +164,36 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
}
/**
- * Proxy method to access protected constructors from sibling classes.
+ * Proxy method to access BigInteger's protected constructor from sibling classes.
*
* @internal
+ * @psalm-pure
+ */
+ protected function newBigInteger(string $value) : BigInteger
+ {
+ return new BigInteger($value);
+ }
+
+ /**
+ * Proxy method to access BigDecimal's protected constructor from sibling classes.
*
- * @param mixed ...$args The arguments to the constructor.
- *
- * @return static
+ * @internal
+ * @psalm-pure
+ */
+ protected function newBigDecimal(string $value, int $scale = 0) : BigDecimal
+ {
+ return new BigDecimal($value, $scale);
+ }
+
+ /**
+ * Proxy method to access BigRational's protected constructor from sibling classes.
*
+ * @internal
* @psalm-pure
- * @psalm-suppress TooManyArguments
- * @psalm-suppress UnsafeInstantiation
*/
- protected static function create(... $args) : BigNumber
+ protected function newBigRational(BigInteger $numerator, BigInteger $denominator, bool $checkDenominator) : BigRational
{
- return new static(... $args);
+ return new BigRational($numerator, $denominator, $checkDenominator);
}
/**
@@ -198,8 +202,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @param BigNumber|int|float|string ...$values The numbers to compare. All the numbers need to be convertible
* to an instance of the class this method is called on.
*
- * @return static The minimum value.
- *
* @throws \InvalidArgumentException If no values are given.
* @throws MathException If an argument is not valid.
*
@@ -207,7 +209,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @psalm-suppress MoreSpecificReturnType
* @psalm-pure
*/
- public static function min(...$values) : BigNumber
+ public static function min(BigNumber|int|float|string ...$values) : static
{
$min = null;
@@ -232,8 +234,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @param BigNumber|int|float|string ...$values The numbers to compare. All the numbers need to be convertible
* to an instance of the class this method is called on.
*
- * @return static The maximum value.
- *
* @throws \InvalidArgumentException If no values are given.
* @throws MathException If an argument is not valid.
*
@@ -241,7 +241,7 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @psalm-suppress MoreSpecificReturnType
* @psalm-pure
*/
- public static function max(...$values) : BigNumber
+ public static function max(BigNumber|int|float|string ...$values) : static
{
$max = null;
@@ -266,18 +266,14 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @param BigNumber|int|float|string ...$values The numbers to add. All the numbers need to be convertible
* to an instance of the class this method is called on.
*
- * @return static The sum.
- *
* @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
+ public static function sum(BigNumber|int|float|string ...$values) : static
{
- /** @var BigNumber|null $sum */
+ /** @var static|null $sum */
$sum = null;
foreach ($values as $value) {
@@ -301,11 +297,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* depending on their ability to perform the operation. This will also require a version bump because we're
* potentially breaking custom BigNumber implementations (if any...)
*
- * @param BigNumber $a
- * @param BigNumber $b
- *
- * @return BigNumber
- *
* @psalm-pure
*/
private static function add(BigNumber $a, BigNumber $b) : BigNumber
@@ -336,8 +327,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
*
* @param string $number The number, validated as a non-empty string of digits with optional leading sign.
*
- * @return string
- *
* @psalm-pure
*/
private static function cleanUp(string $number) : string
@@ -363,68 +352,46 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Checks if this number is equal to the given one.
- *
- * @param BigNumber|int|float|string $that
- *
- * @return bool
*/
- public function isEqualTo($that) : bool
+ public function isEqualTo(BigNumber|int|float|string $that) : bool
{
return $this->compareTo($that) === 0;
}
/**
* Checks if this number is strictly lower than the given one.
- *
- * @param BigNumber|int|float|string $that
- *
- * @return bool
*/
- public function isLessThan($that) : bool
+ public function isLessThan(BigNumber|int|float|string $that) : bool
{
return $this->compareTo($that) < 0;
}
/**
* Checks if this number is lower than or equal to the given one.
- *
- * @param BigNumber|int|float|string $that
- *
- * @return bool
*/
- public function isLessThanOrEqualTo($that) : bool
+ public function isLessThanOrEqualTo(BigNumber|int|float|string $that) : bool
{
return $this->compareTo($that) <= 0;
}
/**
* Checks if this number is strictly greater than the given one.
- *
- * @param BigNumber|int|float|string $that
- *
- * @return bool
*/
- public function isGreaterThan($that) : bool
+ public function isGreaterThan(BigNumber|int|float|string $that) : bool
{
return $this->compareTo($that) > 0;
}
/**
* Checks if this number is greater than or equal to the given one.
- *
- * @param BigNumber|int|float|string $that
- *
- * @return bool
*/
- public function isGreaterThanOrEqualTo($that) : bool
+ public function isGreaterThanOrEqualTo(BigNumber|int|float|string $that) : bool
{
return $this->compareTo($that) >= 0;
}
/**
* Checks if this number equals zero.
- *
- * @return bool
*/
public function isZero() : bool
{
@@ -433,8 +400,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Checks if this number is strictly negative.
- *
- * @return bool
*/
public function isNegative() : bool
{
@@ -443,8 +408,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Checks if this number is negative or zero.
- *
- * @return bool
*/
public function isNegativeOrZero() : bool
{
@@ -453,8 +416,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Checks if this number is strictly positive.
- *
- * @return bool
*/
public function isPositive() : bool
{
@@ -463,8 +424,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Checks if this number is positive or zero.
- *
- * @return bool
*/
public function isPositiveOrZero() : bool
{
@@ -481,19 +440,15 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Compares this number to the given one.
*
- * @param BigNumber|int|float|string $that
- *
* @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`.
*
* @throws MathException If the number is not valid.
*/
- abstract public function compareTo($that) : int;
+ abstract public function compareTo(BigNumber|int|float|string $that) : int;
/**
* Converts this number to a BigInteger.
*
- * @return BigInteger The converted number.
- *
* @throws RoundingNecessaryException If this number cannot be converted to a BigInteger without rounding.
*/
abstract public function toBigInteger() : BigInteger;
@@ -501,16 +456,12 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
/**
* Converts this number to a BigDecimal.
*
- * @return BigDecimal The converted number.
- *
* @throws RoundingNecessaryException If this number cannot be converted to a BigDecimal without rounding.
*/
abstract public function toBigDecimal() : BigDecimal;
/**
* Converts this number to a BigRational.
- *
- * @return BigRational The converted number.
*/
abstract public function toBigRational() : BigRational;
@@ -520,8 +471,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* @param int $scale The scale of the resulting `BigDecimal`.
* @param int $roundingMode A `RoundingMode` constant.
*
- * @return BigDecimal
- *
* @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding.
* This only applies when RoundingMode::UNNECESSARY is used.
*/
@@ -533,8 +482,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
* If this number cannot be converted to a native integer without losing precision, an exception is thrown.
* Note that the acceptable range for an integer depends on the platform and differs for 32-bit and 64-bit.
*
- * @return int The converted value.
- *
* @throws MathException If this number cannot be exactly converted to a native integer.
*/
abstract public function toInt() : int;
@@ -547,8 +494,6 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
*
* If the number is greater than the largest representable floating point number, positive infinity is returned.
* If the number is less than the smallest representable floating point number, negative infinity is returned.
- *
- * @return float The converted value.
*/
abstract public function toFloat() : float;
@@ -557,14 +502,9 @@ abstract class BigNumber implements \Serializable, \JsonSerializable
*
* The output of this method can be parsed by the `of()` factory method;
* this will yield an object equal to this one, without any information loss.
- *
- * @return string
*/
abstract public function __toString() : string;
- /**
- * {@inheritdoc}
- */
public function jsonSerialize() : string
{
return $this->__toString();
diff --git a/vendor/brick/math/src/BigRational.php b/vendor/brick/math/src/BigRational.php
index bee094f73..31f2904fa 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.
@@ -61,15 +57,11 @@ final class BigRational extends BigNumber
/**
* Creates a BigRational of the given value.
*
- * @param BigNumber|int|float|string $value
- *
- * @return BigRational
- *
* @throws MathException If the value cannot be converted to a BigRational.
*
* @psalm-pure
*/
- public static function of($value) : BigNumber
+ public static function of(BigNumber|int|float|string $value) : BigRational
{
return parent::of($value)->toBigRational();
}
@@ -83,16 +75,16 @@ final class BigRational extends BigNumber
* @param BigNumber|int|float|string $numerator The numerator. Must be convertible to a BigInteger.
* @param BigNumber|int|float|string $denominator The denominator. Must be convertible to a BigInteger.
*
- * @return BigRational
- *
* @throws NumberFormatException If an argument does not represent a valid number.
* @throws RoundingNecessaryException If an argument represents a non-integer number.
* @throws DivisionByZeroException If the denominator is zero.
*
* @psalm-pure
*/
- public static function nd($numerator, $denominator) : BigRational
- {
+ public static function nd(
+ BigNumber|int|float|string $numerator,
+ BigNumber|int|float|string $denominator,
+ ) : BigRational {
$numerator = BigInteger::of($numerator);
$denominator = BigInteger::of($denominator);
@@ -102,8 +94,6 @@ final class BigRational extends BigNumber
/**
* Returns a BigRational representing zero.
*
- * @return BigRational
- *
* @psalm-pure
*/
public static function zero() : BigRational
@@ -124,8 +114,6 @@ final class BigRational extends BigNumber
/**
* Returns a BigRational representing one.
*
- * @return BigRational
- *
* @psalm-pure
*/
public static function one() : BigRational
@@ -146,8 +134,6 @@ final class BigRational extends BigNumber
/**
* Returns a BigRational representing ten.
*
- * @return BigRational
- *
* @psalm-pure
*/
public static function ten() : BigRational
@@ -165,17 +151,11 @@ final class BigRational extends BigNumber
return $ten;
}
- /**
- * @return BigInteger
- */
public function getNumerator() : BigInteger
{
return $this->numerator;
}
- /**
- * @return BigInteger
- */
public function getDenominator() : BigInteger
{
return $this->denominator;
@@ -183,8 +163,6 @@ final class BigRational extends BigNumber
/**
* Returns the quotient of the division of the numerator by the denominator.
- *
- * @return BigInteger
*/
public function quotient() : BigInteger
{
@@ -193,8 +171,6 @@ final class BigRational extends BigNumber
/**
* Returns the remainder of the division of the numerator by the denominator.
- *
- * @return BigInteger
*/
public function remainder() : BigInteger
{
@@ -216,11 +192,9 @@ final class BigRational extends BigNumber
*
* @param BigNumber|int|float|string $that The number to add.
*
- * @return BigRational The result.
- *
* @throws MathException If the number is not valid.
*/
- public function plus($that) : BigRational
+ public function plus(BigNumber|int|float|string $that) : BigRational
{
$that = BigRational::of($that);
@@ -236,11 +210,9 @@ final class BigRational extends BigNumber
*
* @param BigNumber|int|float|string $that The number to subtract.
*
- * @return BigRational The result.
- *
* @throws MathException If the number is not valid.
*/
- public function minus($that) : BigRational
+ public function minus(BigNumber|int|float|string $that) : BigRational
{
$that = BigRational::of($that);
@@ -256,11 +228,9 @@ final class BigRational extends BigNumber
*
* @param BigNumber|int|float|string $that The multiplier.
*
- * @return BigRational The result.
- *
* @throws MathException If the multiplier is not a valid number.
*/
- public function multipliedBy($that) : BigRational
+ public function multipliedBy(BigNumber|int|float|string $that) : BigRational
{
$that = BigRational::of($that);
@@ -275,11 +245,9 @@ final class BigRational extends BigNumber
*
* @param BigNumber|int|float|string $that The divisor.
*
- * @return BigRational The result.
- *
* @throws MathException If the divisor is not a valid number, or is zero.
*/
- public function dividedBy($that) : BigRational
+ public function dividedBy(BigNumber|int|float|string $that) : BigRational
{
$that = BigRational::of($that);
@@ -292,10 +260,6 @@ final class BigRational extends BigNumber
/**
* Returns this number exponentiated to the given value.
*
- * @param int $exponent The exponent.
- *
- * @return BigRational The result.
- *
* @throws \InvalidArgumentException If the exponent is not in the range 0 to 1,000,000.
*/
public function power(int $exponent) : BigRational
@@ -322,8 +286,6 @@ final class BigRational extends BigNumber
*
* The reciprocal has the numerator and denominator swapped.
*
- * @return BigRational
- *
* @throws DivisionByZeroException If the numerator is zero.
*/
public function reciprocal() : BigRational
@@ -333,8 +295,6 @@ final class BigRational extends BigNumber
/**
* Returns the absolute value of this BigRational.
- *
- * @return BigRational
*/
public function abs() : BigRational
{
@@ -343,8 +303,6 @@ final class BigRational extends BigNumber
/**
* Returns the negated value of this BigRational.
- *
- * @return BigRational
*/
public function negated() : BigRational
{
@@ -353,8 +311,6 @@ final class BigRational extends BigNumber
/**
* Returns the simplified value of this BigRational.
- *
- * @return BigRational
*/
public function simplified() : BigRational
{
@@ -366,25 +322,16 @@ final class BigRational extends BigNumber
return new BigRational($numerator, $denominator, false);
}
- /**
- * {@inheritdoc}
- */
- public function compareTo($that) : int
+ public function compareTo(BigNumber|int|float|string $that) : int
{
return $this->minus($that)->getSign();
}
- /**
- * {@inheritdoc}
- */
public function getSign() : int
{
return $this->numerator->getSign();
}
- /**
- * {@inheritdoc}
- */
public function toBigInteger() : BigInteger
{
$simplified = $this->simplified();
@@ -396,49 +343,32 @@ final class BigRational extends BigNumber
return $simplified->numerator;
}
- /**
- * {@inheritdoc}
- */
public function toBigDecimal() : BigDecimal
{
return $this->numerator->toBigDecimal()->exactlyDividedBy($this->denominator);
}
- /**
- * {@inheritdoc}
- */
public function toBigRational() : BigRational
{
return $this;
}
- /**
- * {@inheritdoc}
- */
public function toScale(int $scale, int $roundingMode = RoundingMode::UNNECESSARY) : BigDecimal
{
return $this->numerator->toBigDecimal()->dividedBy($this->denominator, $scale, $roundingMode);
}
- /**
- * {@inheritdoc}
- */
public function toInt() : int
{
return $this->toBigInteger()->toInt();
}
- /**
- * {@inheritdoc}
- */
public function toFloat() : float
{
- return $this->numerator->toFloat() / $this->denominator->toFloat();
+ $simplified = $this->simplified();
+ return $simplified->numerator->toFloat() / $simplified->denominator->toFloat();
}
- /**
- * {@inheritdoc}
- */
public function __toString() : string
{
$numerator = (string) $this->numerator;
@@ -471,8 +401,6 @@ final class BigRational extends BigNumber
*
* @param array{numerator: BigInteger, denominator: BigInteger} $data
*
- * @return void
- *
* @throws \LogicException
*/
public function __unserialize(array $data): void
@@ -489,8 +417,6 @@ final class BigRational extends BigNumber
* This method is required by interface Serializable and SHOULD NOT be accessed directly.
*
* @internal
- *
- * @return string
*/
public function serialize() : string
{
@@ -503,10 +429,6 @@ final class BigRational extends BigNumber
* @internal
* @psalm-suppress RedundantPropertyInitializationCheck
*
- * @param string $value
- *
- * @return void
- *
* @throws \LogicException
*/
public function unserialize($value) : void
diff --git a/vendor/brick/math/src/Exception/DivisionByZeroException.php b/vendor/brick/math/src/Exception/DivisionByZeroException.php
index a4e443176..ce7769ac2 100644
--- a/vendor/brick/math/src/Exception/DivisionByZeroException.php
+++ b/vendor/brick/math/src/Exception/DivisionByZeroException.php
@@ -10,8 +10,6 @@ namespace Brick\Math\Exception;
class DivisionByZeroException extends MathException
{
/**
- * @return DivisionByZeroException
- *
* @psalm-pure
*/
public static function divisionByZero() : DivisionByZeroException
@@ -20,8 +18,6 @@ class DivisionByZeroException extends MathException
}
/**
- * @return DivisionByZeroException
- *
* @psalm-pure
*/
public static function modulusMustNotBeZero() : DivisionByZeroException
@@ -30,8 +26,6 @@ class DivisionByZeroException extends MathException
}
/**
- * @return DivisionByZeroException
- *
* @psalm-pure
*/
public static function denominatorMustNotBeZero() : DivisionByZeroException
diff --git a/vendor/brick/math/src/Exception/IntegerOverflowException.php b/vendor/brick/math/src/Exception/IntegerOverflowException.php
index e0b07d3c7..c73b49097 100644
--- a/vendor/brick/math/src/Exception/IntegerOverflowException.php
+++ b/vendor/brick/math/src/Exception/IntegerOverflowException.php
@@ -12,10 +12,6 @@ use Brick\Math\BigInteger;
class IntegerOverflowException extends MathException
{
/**
- * @param BigInteger $value
- *
- * @return IntegerOverflowException
- *
* @psalm-pure
*/
public static function toIntOverflow(BigInteger $value) : IntegerOverflowException
diff --git a/vendor/brick/math/src/Exception/MathException.php b/vendor/brick/math/src/Exception/MathException.php
index 21fda90e1..46e9c3fe4 100644
--- a/vendor/brick/math/src/Exception/MathException.php
+++ b/vendor/brick/math/src/Exception/MathException.php
@@ -6,9 +6,7 @@ namespace Brick\Math\Exception;
/**
* Base class for all math exceptions.
- *
- * This class is abstract to ensure that only fine-grained exceptions are thrown throughout the code.
*/
-class MathException extends \RuntimeException
+class MathException extends \Exception
{
}
diff --git a/vendor/brick/math/src/Exception/NumberFormatException.php b/vendor/brick/math/src/Exception/NumberFormatException.php
index 2fd0be73a..d9cf6ff5f 100644
--- a/vendor/brick/math/src/Exception/NumberFormatException.php
+++ b/vendor/brick/math/src/Exception/NumberFormatException.php
@@ -12,8 +12,6 @@ class NumberFormatException extends MathException
/**
* @param string $char The failing character.
*
- * @return NumberFormatException
- *
* @psalm-pure
*/
public static function charNotInAlphabet(string $char) : self
diff --git a/vendor/brick/math/src/Exception/RoundingNecessaryException.php b/vendor/brick/math/src/Exception/RoundingNecessaryException.php
index 1c6100563..57bfcd844 100644
--- a/vendor/brick/math/src/Exception/RoundingNecessaryException.php
+++ b/vendor/brick/math/src/Exception/RoundingNecessaryException.php
@@ -10,8 +10,6 @@ namespace Brick\Math\Exception;
class RoundingNecessaryException extends MathException
{
/**
- * @return RoundingNecessaryException
- *
* @psalm-pure
*/
public static function roundingNecessary() : RoundingNecessaryException
diff --git a/vendor/brick/math/src/Internal/Calculator.php b/vendor/brick/math/src/Internal/Calculator.php
index a6eac799f..b8cecda96 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.
@@ -45,8 +43,6 @@ abstract class Calculator
* An instance is typically set only in unit tests: the autodetect is usually the best option.
*
* @param Calculator|null $calculator The calculator instance, or NULL to revert to autodetect.
- *
- * @return void
*/
final public static function set(?Calculator $calculator) : void
{
@@ -58,8 +54,6 @@ abstract class Calculator
*
* If none has been explicitly set, the fastest available implementation will be returned.
*
- * @return Calculator
- *
* @psalm-pure
* @psalm-suppress ImpureStaticProperty
*/
@@ -77,8 +71,6 @@ abstract class Calculator
* Returns the fastest available Calculator implementation.
*
* @codeCoverageIgnore
- *
- * @return Calculator
*/
private static function detect() : Calculator
{
@@ -96,9 +88,6 @@ abstract class Calculator
/**
* Extracts the sign & digits of the operands.
*
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
* @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
@@ -114,10 +103,6 @@ abstract class Calculator
/**
* Returns the absolute value of a number.
- *
- * @param string $n The number.
- *
- * @return string The absolute value.
*/
final public function abs(string $n) : string
{
@@ -126,10 +111,6 @@ abstract class Calculator
/**
* Negates a number.
- *
- * @param string $n The number.
- *
- * @return string The negated value.
*/
final public function neg(string $n) : string
{
@@ -147,9 +128,6 @@ abstract class Calculator
/**
* Compares two numbers.
*
- * @param string $a The first number.
- * @param string $b The second number.
- *
* @return int [-1, 0, 1] If the first number is less than, equal to, or greater than the second number.
*/
final public function cmp(string $a, string $b) : int
@@ -180,31 +158,16 @@ abstract class Calculator
/**
* Adds two numbers.
- *
- * @param string $a The augend.
- * @param string $b The addend.
- *
- * @return string The sum.
*/
abstract public function add(string $a, string $b) : string;
/**
* Subtracts two numbers.
- *
- * @param string $a The minuend.
- * @param string $b The subtrahend.
- *
- * @return string The difference.
*/
abstract public function sub(string $a, string $b) : string;
/**
* Multiplies two numbers.
- *
- * @param string $a The multiplicand.
- * @param string $b The multiplier.
- *
- * @return string The product.
*/
abstract public function mul(string $a, string $b) : string;
@@ -234,7 +197,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;
@@ -249,10 +212,7 @@ abstract class Calculator
abstract public function pow(string $a, int $e) : string;
/**
- * @param string $a
* @param string $b The modulus; must not be zero.
- *
- * @return string
*/
public function mod(string $a, string $b) : string
{
@@ -266,10 +226,7 @@ abstract class Calculator
*
* This method can be overridden by the concrete implementation if the underlying library has built-in support.
*
- * @param string $x
* @param string $m The modulus; must not be negative or zero.
- *
- * @return string|null
*/
public function modInverse(string $x, string $m) : ?string
{
@@ -283,9 +240,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;
@@ -300,8 +255,6 @@ abstract class Calculator
* @param string $base The base number; must be positive or zero.
* @param string $exp The exponent; must be positive or zero.
* @param string $mod The modulus; must be strictly positive.
- *
- * @return string The power.
*/
abstract public function modPow(string $base, string $exp, string $mod) : string;
@@ -311,9 +264,6 @@ abstract class Calculator
* This method can be overridden by the concrete implementation if the underlying library
* has built-in support for GCD calculations.
*
- * @param string $a The first number.
- * @param string $b The second number.
- *
* @return string The GCD, always positive, or zero if both arguments are zero.
*/
public function gcd(string $a, string $b) : string
@@ -329,24 +279,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];
}
/**
@@ -354,10 +301,6 @@ abstract class Calculator
*
* The result is the largest x such that x² ≤ n.
* The input MUST NOT be negative.
- *
- * @param string $n The number.
- *
- * @return string The square root.
*/
abstract public function sqrt(string $n) : string;
@@ -489,10 +432,10 @@ abstract class Calculator
* @param string $b The divisor, must not be zero.
* @param int $roundingMode The rounding mode.
*
- * @return string
- *
* @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
{
@@ -570,11 +513,6 @@ abstract class Calculator
*
* This method can be overridden by the concrete implementation if the underlying library
* has built-in support for bitwise operations.
- *
- * @param string $a
- * @param string $b
- *
- * @return string
*/
public function and(string $a, string $b) : string
{
@@ -586,11 +524,6 @@ abstract class Calculator
*
* This method can be overridden by the concrete implementation if the underlying library
* has built-in support for bitwise operations.
- *
- * @param string $a
- * @param string $b
- *
- * @return string
*/
public function or(string $a, string $b) : string
{
@@ -602,11 +535,6 @@ abstract class Calculator
*
* This method can be overridden by the concrete implementation if the underlying library
* has built-in support for bitwise operations.
- *
- * @param string $a
- * @param string $b
- *
- * @return string
*/
public function xor(string $a, string $b) : string
{
@@ -616,11 +544,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.
- *
- * @return string
+ * @param 'and'|'or'|'xor' $operator The operator to use.
+ * @param string $a The left operand.
+ * @param string $b The right operand.
*/
private function bitwise(string $operator, string $a, string $b) : string
{
@@ -678,8 +604,6 @@ abstract class Calculator
/**
* @param string $number A positive, binary number.
- *
- * @return string
*/
private function twosComplement(string $number) : string
{
@@ -709,8 +633,6 @@ abstract class Calculator
* Converts a decimal number to a binary string.
*
* @param string $number The number to convert, positive or zero, only digits.
- *
- * @return string
*/
private function toBinary(string $number) : string
{
@@ -728,8 +650,6 @@ abstract class Calculator
* Returns the positive decimal representation of a binary number.
*
* @param string $bytes The bytes representing the number.
- *
- * @return string
*/
private function toDecimal(string $bytes) : string
{
diff --git a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
index 6632b378a..5457a3c98 100644
--- a/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
@@ -15,99 +15,58 @@ use Brick\Math\Internal\Calculator;
*/
class BcMathCalculator extends Calculator
{
- /**
- * {@inheritdoc}
- */
public function add(string $a, string $b) : string
{
return \bcadd($a, $b, 0);
}
- /**
- * {@inheritdoc}
- */
public function sub(string $a, string $b) : string
{
return \bcsub($a, $b, 0);
}
- /**
- * {@inheritdoc}
- */
public function mul(string $a, string $b) : string
{
return \bcmul($a, $b, 0);
}
- /**
- * {@inheritdoc}
- *
- * @psalm-suppress InvalidNullableReturnType
- * @psalm-suppress NullableReturnStatement
- */
public function divQ(string $a, string $b) : string
{
return \bcdiv($a, $b, 0);
}
/**
- * {@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);
+ return \bcmod($a, $b, 0);
}
- /**
- * {@inheritdoc}
- */
public function divQR(string $a, string $b) : array
{
$q = \bcdiv($a, $b, 0);
+ $r = \bcmod($a, $b, 0);
- 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];
}
- /**
- * {@inheritdoc}
- */
public function pow(string $a, int $e) : string
{
return \bcpow($a, (string) $e, 0);
}
- /**
- * {@inheritdoc}
- *
- * @psalm-suppress InvalidNullableReturnType
- * @psalm-suppress NullableReturnStatement
- */
public function modPow(string $base, string $exp, string $mod) : string
{
return \bcpowmod($base, $exp, $mod, 0);
}
/**
- * {@inheritDoc}
- *
- * @psalm-suppress NullableReturnStatement
* @psalm-suppress InvalidNullableReturnType
+ * @psalm-suppress NullableReturnStatement
*/
public function sqrt(string $n) : string
{
diff --git a/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php b/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php
index 52d18800a..42d4c6927 100644
--- a/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php
@@ -15,49 +15,31 @@ use Brick\Math\Internal\Calculator;
*/
class GmpCalculator extends Calculator
{
- /**
- * {@inheritdoc}
- */
public function add(string $a, string $b) : string
{
return \gmp_strval(\gmp_add($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function sub(string $a, string $b) : string
{
return \gmp_strval(\gmp_sub($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function mul(string $a, string $b) : string
{
return \gmp_strval(\gmp_mul($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function divQ(string $a, string $b) : string
{
return \gmp_strval(\gmp_div_q($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function divR(string $a, string $b) : string
{
return \gmp_strval(\gmp_div_r($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function divQR(string $a, string $b) : array
{
[$q, $r] = \gmp_div_qr($a, $b);
@@ -68,17 +50,11 @@ class GmpCalculator extends Calculator
];
}
- /**
- * {@inheritdoc}
- */
public function pow(string $a, int $e) : string
{
return \gmp_strval(\gmp_pow($a, $e));
}
- /**
- * {@inheritdoc}
- */
public function modInverse(string $x, string $m) : ?string
{
$result = \gmp_invert($x, $m);
@@ -90,65 +66,41 @@ class GmpCalculator extends Calculator
return \gmp_strval($result);
}
- /**
- * {@inheritdoc}
- */
public function modPow(string $base, string $exp, string $mod) : string
{
return \gmp_strval(\gmp_powm($base, $exp, $mod));
}
- /**
- * {@inheritdoc}
- */
public function gcd(string $a, string $b) : string
{
return \gmp_strval(\gmp_gcd($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function fromBase(string $number, int $base) : string
{
return \gmp_strval(\gmp_init($number, $base));
}
- /**
- * {@inheritdoc}
- */
public function toBase(string $number, int $base) : string
{
return \gmp_strval($number, $base);
}
- /**
- * {@inheritdoc}
- */
public function and(string $a, string $b) : string
{
return \gmp_strval(\gmp_and($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function or(string $a, string $b) : string
{
return \gmp_strval(\gmp_or($a, $b));
}
- /**
- * {@inheritdoc}
- */
public function xor(string $a, string $b) : string
{
return \gmp_strval(\gmp_xor($a, $b));
}
- /**
- * {@inheritDoc}
- */
public function sqrt(string $n) : string
{
return \gmp_strval(\gmp_sqrt($n));
diff --git a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
index 020a6338b..7c679d24d 100644
--- a/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
+++ b/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
@@ -19,17 +19,13 @@ class NativeCalculator extends Calculator
* The max number of digits the platform can natively add, subtract, multiply or divide without overflow.
* For multiplication, this represents the max sum of the lengths of both operands.
*
- * For addition, it is assumed that an extra digit can hold a carry (1) without overflowing.
+ * In 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.
- *
* @codeCoverageIgnore
*/
public function __construct()
@@ -48,9 +44,6 @@ class NativeCalculator extends Calculator
}
}
- /**
- * {@inheritdoc}
- */
public function add(string $a, string $b) : string
{
/**
@@ -82,17 +75,11 @@ class NativeCalculator extends Calculator
return $result;
}
- /**
- * {@inheritdoc}
- */
public function sub(string $a, string $b) : string
{
return $this->add($a, $this->neg($b));
}
- /**
- * {@inheritdoc}
- */
public function mul(string $a, string $b) : string
{
/**
@@ -136,25 +123,16 @@ class NativeCalculator extends Calculator
return $result;
}
- /**
- * {@inheritdoc}
- */
public function divQ(string $a, string $b) : string
{
return $this->divQR($a, $b)[0];
}
- /**
- * {@inheritdoc}
- */
public function divR(string $a, string $b): string
{
return $this->divQR($a, $b)[1];
}
- /**
- * {@inheritdoc}
- */
public function divQR(string $a, string $b) : array
{
if ($a === '0') {
@@ -210,9 +188,6 @@ class NativeCalculator extends Calculator
return [$q, $r];
}
- /**
- * {@inheritdoc}
- */
public function pow(string $a, int $e) : string
{
if ($e === 0) {
@@ -240,8 +215,6 @@ class NativeCalculator extends Calculator
/**
* Algorithm from: https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/
- *
- * {@inheritdoc}
*/
public function modPow(string $base, string $exp, string $mod) : string
{
@@ -276,8 +249,6 @@ class NativeCalculator extends Calculator
/**
* Adapted from https://cp-algorithms.com/num_methods/roots_newton.html
- *
- * {@inheritDoc}
*/
public function sqrt(string $n) : string
{
@@ -306,11 +277,6 @@ class NativeCalculator extends Calculator
/**
* Performs the addition of two non-signed large integers.
- *
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
- * @return string
*/
private function doAdd(string $a, string $b) : string
{
@@ -363,11 +329,6 @@ class NativeCalculator extends Calculator
/**
* Performs the subtraction of two non-signed large integers.
- *
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
- * @return string
*/
private function doSub(string $a, string $b) : string
{
@@ -445,11 +406,6 @@ class NativeCalculator extends Calculator
/**
* Performs the multiplication of two non-signed large integers.
- *
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
- * @return string
*/
private function doMul(string $a, string $b) : string
{
@@ -522,9 +478,6 @@ class NativeCalculator extends Calculator
/**
* Performs the division of two non-signed large integers.
*
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
* @return string[] The quotient and remainder.
*/
private function doDiv(string $a, string $b) : array
@@ -583,9 +536,6 @@ class NativeCalculator extends Calculator
/**
* Compares two non-signed large numbers.
*
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
* @return int [-1, 0, 1]
*/
private function doCmp(string $a, string $b) : int
@@ -607,9 +557,6 @@ class NativeCalculator extends Calculator
*
* The numbers must only consist of digits, without leading minus sign.
*
- * @param string $a The first operand.
- * @param string $b The second operand.
- *
* @return array{string, string, int}
*/
private function pad(string $a, string $b) : array