updated composer

This commit is contained in:
2021-05-18 13:47:03 +00:00
parent e248cd036c
commit ba92152daa
1187 changed files with 20804 additions and 22320 deletions
+14 -8
View File
@@ -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
*
+21 -4
View File
@@ -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
*
+24 -18
View File
@@ -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) {
+13 -3
View File
@@ -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
*
+4 -1
View File
@@ -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]);
@@ -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
{
@@ -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;
}