diff --git a/.gitignore b/.gitignore index 4901aab..8ae88e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /vendor /composer.lock -/.phpunit.result.cache +/.phpunit.cache diff --git a/composer.json b/composer.json index 17b163c..95d67dd 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^10.0", "php-coveralls/php-coveralls": "^2.2", "vimeo/psalm": "5.14.1" }, diff --git a/phpunit.xml b/phpunit.xml index a292a18..bfaec18 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,13 @@ - + tests - + - src + src - + diff --git a/tests/BigDecimalTest.php b/tests/BigDecimalTest.php index f8d3443..700d4c4 100644 --- a/tests/BigDecimalTest.php +++ b/tests/BigDecimalTest.php @@ -29,7 +29,7 @@ public function testOf($value, string $unscaledValue, int $scale) : void self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($value)); } - public function providerOf() : array + public static function providerOf() : array { return [ [0, '0', 0], @@ -206,7 +206,7 @@ public function testOfFloatInDifferentLocales(string $locale) : void setlocale(LC_NUMERIC, $originalLocale); } - public function providerOfFloatInDifferentLocales() : array + public static function providerOfFloatInDifferentLocales() : array { return [ ['C'], @@ -231,7 +231,7 @@ public function testOfInvalidValueThrowsException($value) : void BigDecimal::of($value); } - public function providerOfInvalidValueThrowsException() : array + public static function providerOfInvalidValueThrowsException() : array { return [ [''], @@ -282,7 +282,7 @@ public function testOfUnscaledValue($unscaledValue, int $scale, string $expected self::assertBigDecimalInternalValues($expectedUnscaledValue, $scale, $number); } - public function providerOfUnscaledValue() : array + public static function providerOfUnscaledValue() : array { return [ [123456789, 0, '123456789'], @@ -347,7 +347,7 @@ public function testMin(array $values, string $min) : void self::assertBigDecimalEquals($min, BigDecimal::min(... $values)); } - public function providerMin() : array + public static function providerMin() : array { return [ [[0, 1, -1], '-1'], @@ -388,7 +388,7 @@ public function testMax(array $values, string $max) : void self::assertBigDecimalEquals($max, BigDecimal::max(... $values)); } - public function providerMax() : array + public static function providerMax() : array { return [ [[0, 0.9, -1.00], '0.9'], @@ -433,7 +433,7 @@ public function testSum(array $values, string $sum) : void self::assertBigDecimalEquals($sum, BigDecimal::sum(... $values)); } - public function providerSum() : array + public static function providerSum() : array { return [ [[0, 0.9, -1.00], '-0.1'], @@ -480,7 +480,7 @@ public function testPlus(string $a, string $b, string $unscaledValue, int $scale self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->plus($b)); } - public function providerPlus() : array + public static function providerPlus() : array { return [ ['123', '999', '1122', 0], @@ -556,7 +556,7 @@ public function testMinus(string $a, string $b, string $unscaledValue, int $scal self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->minus($b)); } - public function providerMinus() : array + public static function providerMinus() : array { return [ ['123', '999', '-876', 0], @@ -625,7 +625,7 @@ public function testMultipliedBy(string $a, string $b, string $unscaledValue, in self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($a)->multipliedBy($b)); } - public function providerMultipliedBy() : array + public static function providerMultipliedBy() : array { return [ ['123', '999', '122877', 0], @@ -739,7 +739,7 @@ public function testDividedBy(string $a, string $b, ?int $scale, int $roundingMo self::assertBigDecimalInternalValues($unscaledValue, $expectedScale, $decimal); } - public function providerDividedBy() : array + public static function providerDividedBy() : array { return [ [ '7', '0.2', 0, RoundingMode::UNNECESSARY, '35', 0], @@ -774,7 +774,7 @@ public function testDividedByByZeroThrowsException($zero) : void BigDecimal::of(1)->dividedBy($zero, 0); } - public function providerDividedByByZeroThrowsException() : array + public static function providerDividedByByZeroThrowsException() : array { return [ [0], @@ -807,7 +807,7 @@ public function testExactlyDividedBy($number, $divisor, string $expected) : void } } - public function providerExactlyDividedBy() : array + public static function providerExactlyDividedBy() : array { return [ [1, 1, '1'], @@ -860,7 +860,7 @@ public function testDividedByWithRoundingNecessaryThrowsException(string $a, str BigDecimal::of($a)->dividedBy($b, $scale); } - public function providerDividedByWithRoundingNecessaryThrowsException() : array + public static function providerDividedByWithRoundingNecessaryThrowsException() : array { return [ ['1.234', '123.456', 3], @@ -921,7 +921,7 @@ private function doTestRoundingMode(int $roundingMode, BigDecimal $number, strin } } - public function providerRoundingMode() : array + public static function providerRoundingMode() : array { return [ [RoundingMode::UP, '3.501', '351', '36', '4'], @@ -1407,7 +1407,7 @@ public function testQuotientAndRemainder(string $dividend, string $divisor, stri self::assertBigDecimalEquals($remainder, $r); } - public function providerQuotientAndRemainder() : array + public static function providerQuotientAndRemainder() : array { return [ ['1', '123', '0', '1'], @@ -1504,7 +1504,7 @@ public function testSqrt(string $number, int $scale, string $sqrt) : void self::assertBigDecimalEquals($sqrt, $number->sqrt($scale)); } - public function providerSqrt() : array + public static function providerSqrt() : array { return [ ['0', 0, '0'], @@ -1728,7 +1728,7 @@ public function testPower(string $number, int $exponent, string $unscaledValue, self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->power($exponent)); } - public function providerPower() : array + public static function providerPower() : array { return [ ['-3', 0, '1', 0], @@ -1788,7 +1788,7 @@ public function testPowerWithInvalidExponentThrowsException(int $power) : void BigDecimal::of(1)->power($power); } - public function providerPowerWithInvalidExponentThrowsException() : array + public static function providerPowerWithInvalidExponentThrowsException() : array { return [ [-1], @@ -1797,7 +1797,7 @@ public function providerPowerWithInvalidExponentThrowsException() : array } /** - * @dataProvider toScaleProvider + * @dataProvider providerToScale * * @param string $number The number to scale. * @param int $toScale The scale to apply. @@ -1811,7 +1811,7 @@ public function testToScale(string $number, int $toScale, int $roundingMode, str self::assertBigDecimalInternalValues($unscaledValue, $scale, $decimal); } - public function toScaleProvider() : array + public static function providerToScale() : array { return [ ['123.45', 0, RoundingMode::DOWN, '123', 0], @@ -1833,7 +1833,7 @@ public function testWithPointMovedLeft(string $number, int $places, string $expe self::assertBigDecimalEquals($expected, BigDecimal::of($number)->withPointMovedLeft($places)); } - public function providerWithPointMovedLeft() : array + public static function providerWithPointMovedLeft() : array { return [ ['0', -2, '0'], @@ -1916,7 +1916,7 @@ public function testWithPointMovedRight(string $number, int $places, string $exp self::assertBigDecimalEquals($expected, BigDecimal::of($number)->withPointMovedRight($places)); } - public function providerWithPointMovedRight() : array + public static function providerWithPointMovedRight() : array { return [ ['0', -2, '0.00'], @@ -1998,7 +1998,7 @@ public function testStripTrailingZeros(string $number, string $expected) : void self::assertBigDecimalEquals($expected, BigDecimal::of($number)->stripTrailingZeros()); } - public function providerStripTrailingZeros() : array + public static function providerStripTrailingZeros() : array { return [ ['0', '0'], @@ -2044,7 +2044,7 @@ public function testAbs(string $number, string $unscaledValue, int $scale) : voi self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->abs()); } - public function providerAbs() : array + public static function providerAbs() : array { return [ ['123', '123', 0], @@ -2066,7 +2066,7 @@ public function testNegated(string $number, string $unscaledValue, int $scale) : self::assertBigDecimalInternalValues($unscaledValue, $scale, BigDecimal::of($number)->negated()); } - public function providerNegated() : array + public static function providerNegated() : array { return [ ['123', '-123', 0], @@ -2148,7 +2148,7 @@ public function testIsGreaterThanOrEqualTo(string $a, $b, int $c) : void self::assertSame($c >= 0, BigDecimal::of($a)->isGreaterThanOrEqualTo($b)); } - public function providerCompareTo() : array + public static function providerCompareTo() : array { return [ ['123', '123', 0], @@ -2263,7 +2263,7 @@ public function testIsPositiveOrZero($number, int $sign) : void self::assertSame($sign >= 0, BigDecimal::of($number)->isPositiveOrZero()); } - public function providerSign() : array + public static function providerSign() : array { return [ [ 0, 0], @@ -2307,7 +2307,7 @@ public function testGetIntegralPart(string $number, string $expected) : void self::assertSame($expected, BigDecimal::of($number)->getIntegralPart()); } - public function providerGetIntegralPart() : array + public static function providerGetIntegralPart() : array { return [ ['1.23', '1'], @@ -2331,7 +2331,7 @@ public function testGetFractionalPart(string $number, string $expected) : void self::assertSame($expected, BigDecimal::of($number)->getFractionalPart()); } - public function providerGetFractionalPart() : array + public static function providerGetFractionalPart() : array { return [ ['1.23', '23'], @@ -2354,7 +2354,7 @@ public function testHasNonZeroFractionalPart(string $number, bool $hasNonZeroFra self::assertSame($hasNonZeroFractionalPart, BigDecimal::of($number)->hasNonZeroFractionalPart()); } - public function providerHasNonZeroFractionalPart() : array + public static function providerHasNonZeroFractionalPart() : array { return [ ['1', false], @@ -2377,7 +2377,7 @@ public function testToBigInteger(string $decimal, string $expected) : void self::assertBigIntegerEquals($expected, BigDecimal::of($decimal)->toBigInteger()); } - public function providerToBigInteger() : array + public static function providerToBigInteger() : array { return [ ['0', '0'], @@ -2399,7 +2399,7 @@ public function testToBigIntegerThrowsExceptionWhenRoundingNecessary(string $dec BigDecimal::of($decimal)->toBigInteger(); } - public function providerToBigIntegerThrowsExceptionWhenRoundingNecessary() : array + public static function providerToBigIntegerThrowsExceptionWhenRoundingNecessary() : array { return [ ['0.1'], @@ -2425,7 +2425,7 @@ public function testToBigRational(string $decimal, string $rational) : void self::assertBigRationalEquals($rational, BigDecimal::of($decimal)->toBigRational()); } - public function providerToBigRational() : array + public static function providerToBigRational() : array { return [ ['0', '0'], @@ -2469,7 +2469,7 @@ public function testToInt(int $number) : void self::assertSame($number, BigDecimal::of($number . '.0')->toInt()); } - public function providerToInt() : array + public static function providerToInt() : array { return [ [PHP_INT_MIN], @@ -2493,7 +2493,7 @@ public function testToIntThrowsException(string $number) : void BigDecimal::of($number)->toInt(); } - public function providerToIntThrowsException() : array + public static function providerToIntThrowsException() : array { return [ ['-999999999999999999999999999999'], @@ -2514,7 +2514,7 @@ public function testToFloat(string $value, float $float) : void self::assertSame($float, BigDecimal::of($value)->toFloat()); } - public function providerToFloat() : array + public static function providerToFloat() : array { return [ ['0', 0.0], @@ -2539,7 +2539,7 @@ public function testToString(string $unscaledValue, int $scale, string $expected self::assertSame($expected, (string) BigDecimal::ofUnscaledValue($unscaledValue, $scale)); } - public function providerToString() : array + public static function providerToString() : array { return [ ['0', 0, '0'], diff --git a/tests/BigIntegerTest.php b/tests/BigIntegerTest.php index 2c4aa89..54e9301 100644 --- a/tests/BigIntegerTest.php +++ b/tests/BigIntegerTest.php @@ -32,7 +32,7 @@ public function testOf($value, string $expected) : void self::assertBigIntegerEquals($expected, BigInteger::of($value)); } - public function providerOf() : array + public static function providerOf() : array { return [ [0, '0'], @@ -122,7 +122,7 @@ public function testOfInvalidFormatThrowsException($value) : void BigInteger::of($value); } - public function providerOfInvalidFormatThrowsException() : array + public static function providerOfInvalidFormatThrowsException() : array { return [ [''], @@ -151,7 +151,7 @@ public function testOfNonConvertibleValueThrowsException($value) : void BigInteger::of($value); } - public function providerOfNonConvertibleValueThrowsException() : array + public static function providerOfNonConvertibleValueThrowsException() : array { return [ [1.1], @@ -175,7 +175,7 @@ public function testFromBase(string $number, int $base, string $expected) : void /** * @return array */ - public function providerFromBase() : array + public static function providerFromBase() : array { return [ ['0', 10, '0'], @@ -289,7 +289,7 @@ public function testFromBaseWithInvalidValue(string $value, int $base) : void BigInteger::fromBase($value, $base); } - public function providerFromBaseWithInvalidValue() : array + public static function providerFromBaseWithInvalidValue() : array { return [ ['', 10], @@ -345,7 +345,7 @@ public function testFromBaseWithInvalidBase(int $base) : void BigInteger::fromBase('0', $base); } - public function providerFromBaseWithInvalidBase() : array + public static function providerFromBaseWithInvalidBase() : array { return [ [-2], @@ -387,7 +387,7 @@ public function testGcdMultiple(array $values, string $expectedGCD): void self::assertSame($expectedGCD, (string) $actualGCD); } - public function providerGcdMultiple(): Generator + public static function providerGcdMultiple(): Generator { // 1 value foreach (['-2', '-1', '0', '1', '2'] as $value) { @@ -395,7 +395,7 @@ public function providerGcdMultiple(): Generator } // 2 values - foreach ($this->providerGcd() as [$a, $b, $gcd]) { + foreach (self::providerGcd() as [$a, $b, $gcd]) { yield [[$a, $b], $gcd]; } @@ -425,7 +425,7 @@ public function testMin(array $values, string $min) : void self::assertBigIntegerEquals($min, BigInteger::min(... $values)); } - public function providerMin() : array + public static function providerMin() : array { return [ [[0, 1, -1], '-1'], @@ -461,7 +461,7 @@ public function testMax(array $values, string $max) : void self::assertBigIntegerEquals($max, BigInteger::max(... $values)); } - public function providerMax() : array + public static function providerMax() : array { return [ [[0, 1, -1], '1'], @@ -498,7 +498,7 @@ public function testSum(array $values, string $sum) : void self::assertBigIntegerEquals($sum, BigInteger::sum(... $values)); } - public function providerSum() : array + public static function providerSum() : array { return [ [[-1], '-1'], @@ -537,7 +537,7 @@ public function testPlus(string $a, string $b, string $r) : void self::assertBigIntegerEquals($r, BigInteger::of($a)->plus($b)); } - public function providerPlus() : array + public static function providerPlus() : array { return [ ['5165450198704521651351654564564089798441', '0', '5165450198704521651351654564564089798441'], @@ -566,7 +566,7 @@ public function testMinus(string $a, string $b, string $r) : void self::assertBigIntegerEquals($r, BigInteger::of($a)->minus($b)); } - public function providerMinus() : array + public static function providerMinus() : array { return [ ['5165450198704521651351654564564089798441', '0', '5165450198704521651351654564564089798441'], @@ -593,7 +593,7 @@ public function testMultipliedBy(string $a, $b, string $r) : void self::assertBigIntegerEquals($r, BigInteger::of($a)->multipliedBy($b)); } - public function providerMultipliedBy() : array + public static function providerMultipliedBy() : array { return [ ['123456789098765432101234567890987654321', '1', '123456789098765432101234567890987654321'], @@ -637,7 +637,7 @@ public function testDividedBy(string $number, $divisor, string $expected) : void } } - public function providerDividedBy() : array + public static function providerDividedBy() : array { return [ ['123456789098765432101234567890987654321', 1, '123456789098765432101234567890987654321'], @@ -708,7 +708,7 @@ private function doTestDividedByWithRoundingMode(int $roundingMode, BigInteger $ } } - public function providerDividedByWithRoundingMode() : array + public static function providerDividedByWithRoundingMode() : array { return [ [RoundingMode::UP, '3501', '351', '36', '4'], @@ -1226,7 +1226,7 @@ public function testQuotientAndRemainder(string $dividend, string $divisor, stri self::assertBigIntegerEquals($remainder, $r); } - public function providerQuotientAndRemainder() : array + public static function providerQuotientAndRemainder() : array { return [ ['1', '123', '0', '1'], @@ -1302,7 +1302,7 @@ public function testMod(string $dividend, string $divisor, string $expected) : v self::assertBigIntegerEquals($expected, BigInteger::of($dividend)->mod($divisor)); } - public function providerMod() : array + public static function providerMod() : array { return [ ['0', '1', '0'], @@ -1399,7 +1399,7 @@ public function testModPow(string $base, string $exp, string $mod, string $expec self::assertBigIntegerEquals($expected, BigInteger::of($base)->modPow($exp, $mod)); } - public function providerModPow() : array + public static function providerModPow() : array { return [ ['0', '0', '1', '0'], @@ -1476,7 +1476,7 @@ public function testModPowNegativeThrowsException(int $base, int $exp, int $mod) BigInteger::of($base)->modPow($exp, $mod); } - public function providerModPowNegativeThrowsException() : array + public static function providerModPowNegativeThrowsException() : array { return [ [ 1, 1, -1], @@ -1503,7 +1503,7 @@ public function testPower(string $number, int $exponent, string $expected) : voi self::assertBigIntegerEquals($expected, BigInteger::of($number)->power($exponent)); } - public function providerPower() : array + public static function providerPower() : array { return [ ['-3', 0, '1'], @@ -1561,7 +1561,7 @@ public function testPowerWithInvalidExponentThrowsException(int $power) : void BigInteger::of(1)->power($power); } - public function providerPowerWithInvalidExponentThrowsException() : array + public static function providerPowerWithInvalidExponentThrowsException() : array { return [ [-1], @@ -1584,7 +1584,7 @@ public function testGcd(string $a, string $b, string $gcd) : void self::assertBigIntegerEquals($gcd, $a->gcd($b)); } - public function providerGcd() : \Generator + public static function providerGcd() : \Generator { $tests = [ ['0', '0', '0'], @@ -1679,7 +1679,7 @@ public function testSqrt(string $number, string $sqrt) : void self::assertBigIntegerEquals($sqrt, $number->sqrt()); } - public function providerSqrt() : array + public static function providerSqrt() : array { return [ ['0', '0'], @@ -2039,7 +2039,7 @@ public function testAbs(string $number, string $expected) : void self::assertBigIntegerEquals($expected, BigInteger::of($number)->abs()); } - public function providerAbs() : array + public static function providerAbs() : array { return [ ['0', '0'], @@ -2059,7 +2059,7 @@ public function testNegated(string $number, string $expected) : void self::assertBigIntegerEquals($expected, BigInteger::of($number)->negated()); } - public function providerNegated() : array + public static function providerNegated() : array { return [ ['0', '0'], @@ -2080,7 +2080,7 @@ public function testOr(string $a, string $b, string $c) : void self::assertBigIntegerEquals($c, BigInteger::of($a)->or($b)); } - public function providerOr() : array + public static function providerOr() : array { return [ ['-1', '-2', '-1'], @@ -2152,7 +2152,7 @@ public function testAnd(string $a, string $b, string $c) : void self::assertBigIntegerEquals($c, BigInteger::of($a)->and($b)); } - public function providerAnd() : array + public static function providerAnd() : array { return [ ['-1', '-2', '-2'], @@ -2229,7 +2229,7 @@ public function testXor(string $a, string $b, string $c) : void self::assertBigIntegerEquals($c, BigInteger::of($a)->xor($b)); } - public function providerXor() : array + public static function providerXor() : array { return [ ['-1', '-2', '1'], @@ -2299,7 +2299,7 @@ public function testNot(string $number, string $expected) : void self::assertBigIntegerEquals($expected, BigInteger::of($number)->not()); } - public function providerNot() : array + public static function providerNot() : array { return [ ['-32769', '32768'], @@ -2348,7 +2348,7 @@ public function testShiftedRight(string $a, int $b, string $c) : void self::assertBigIntegerEquals($c, BigInteger::of($a)->shiftedRight(- $b)); } - public function providerShiftedLeft() : array + public static function providerShiftedLeft() : array { return [ ['-1', 1, '-2'], @@ -2504,7 +2504,7 @@ public function testGetBitLength(string $number, int $bitLength) : void self::assertSame($bitLength, BigInteger::of($number)->getBitLength()); } - public function providerGetBitLength() : array + public static function providerGetBitLength() : array { return [ ['-10141204801825835211973625643009', 104], @@ -2581,7 +2581,7 @@ public function testGetLowestSetBit(string $number, int $lowestSetBit) : void self::assertSame($lowestSetBit, BigInteger::of($number)->getLowestSetBit()); } - public function providerGetLowestSetBit() : array + public static function providerGetLowestSetBit() : array { return [ ['-10', 1], @@ -2638,7 +2638,7 @@ public function testIsOdd(string $number, bool $isOdd) : void self::assertSame($isOdd, BigInteger::of($number)->isOdd()); } - public function providerIsOdd() : \Generator + public static function providerIsOdd() : \Generator { $tests = [ ['123456789012345678900', false], @@ -2671,7 +2671,7 @@ public function testTestBit(BigInteger $number, int $n, bool $expected) : void self::assertSame($expected, $number->testBit($n)); } - public function providerTestBit() : \Generator + public static function providerTestBit() : \Generator { $base2BitsSetTests = [ ['0', []], @@ -2743,7 +2743,7 @@ public function testModInverse(string $x, string $m, string $expectedResult) : v self::assertSame($expectedResult, (string) $x->modInverse($m)); } - public function providerModInverse() : array + public static function providerModInverse() : array { return [ ['1', '1', '0'], @@ -2775,7 +2775,7 @@ public function testModInverseThrows(string $x, string $m, string $expectedExcep $x->modInverse($m); } - public function providerModInverseThrows() : array + public static function providerModInverseThrows() : array { return [ ['0', '0', DivisionByZeroException::class], @@ -2861,7 +2861,7 @@ public function testIsGreaterThanOrEqualTo(string $a, string $b, int $c) : void self::assertSame($c >= 0, BigInteger::of($a)->isGreaterThanOrEqualTo($b)); } - public function providerCompareTo() : array + public static function providerCompareTo() : array { return [ ['123', '123', 0], @@ -2970,7 +2970,7 @@ public function testIsPositiveOrZero($number, int $sign) : void self::assertSame($sign >= 0, BigInteger::of($number)->isPositiveOrZero()); } - public function providerSign() : array + public static function providerSign() : array { return [ [ 0, 0], @@ -2998,7 +2998,7 @@ public function testToScale(string $number, int $scale, string $expected) : void self::assertBigDecimalEquals($expected, BigInteger::of($number)->toScale($scale)); } - public function providerToScale() : array + public static function providerToScale() : array { return [ ['12345678901234567890123456789', 0, '12345678901234567890123456789'], @@ -3015,7 +3015,7 @@ public function testToInt(int $number) : void self::assertSame($number, BigInteger::of((string) $number)->toInt()); } - public function providerToInt() : array + public static function providerToInt() : array { return [ [PHP_INT_MIN], @@ -3051,7 +3051,7 @@ public function testToFloat(string $value, float $float) : void self::assertSame($float, BigInteger::of($value)->toFloat()); } - public function providerToFloat() : array + public static function providerToFloat() : array { return [ ['0', 0.0], @@ -3076,7 +3076,7 @@ public function testToBase(string $number, int $base, string $expected) : void self::assertSame($expected, BigInteger::of($number)->toBase($base)); } - public function providerToBase() : \Generator + public static function providerToBase() : \Generator { $tests = [ ['640998479760579495168036691627608949', 36, '110011001100110011001111'], @@ -3176,7 +3176,7 @@ public function testToInvalidBaseThrowsException(int $base) : void BigInteger::of(0)->toBase($base); } - public function providerToInvalidBaseThrowsException() : array + public static function providerToInvalidBaseThrowsException() : array { return [ [-2], @@ -3197,9 +3197,9 @@ public function testFromArbitraryBase(string $base10, string $alphabet, string $ self::assertBigIntegerEquals($base10, $number); } - public function providerFromArbitraryBase() : \Generator + public static function providerFromArbitraryBase() : \Generator { - foreach ($this->providerArbitraryBase() as [$base10, $alphabet, $baseN]) { + foreach (self::providerArbitraryBase() as [$base10, $alphabet, $baseN]) { yield [$base10, $alphabet, $baseN]; // test with a number of leading "zeros" @@ -3219,7 +3219,7 @@ public function testToArbitraryBase(string $base10, string $alphabet, string $ba self::assertSame($baseN, $actual); } - public function providerArbitraryBase() : array + public static function providerArbitraryBase() : array { $base7 = '0123456'; $base8 = '01234567'; @@ -3316,7 +3316,7 @@ public function testFromArbitraryBaseWithInvalidNumber(string $number, string $a BigInteger::fromArbitraryBase($number, $alphabet); } - public function providerFromArbitraryBaseWithInvalidNumber() : array + public static function providerFromArbitraryBaseWithInvalidNumber() : array { return [ ['', '01', 'The number cannot be empty.'], @@ -3345,7 +3345,7 @@ public function testToArbitraryBaseWithInvalidAlphabet(string $alphabet) : void $number->toArbitraryBase($alphabet); } - public function providerArbitraryBaseWithInvalidAlphabet() : array + public static function providerArbitraryBaseWithInvalidAlphabet() : array { return [ [''], @@ -3372,9 +3372,9 @@ public function testFromBytes(string $byteStringHex, bool $signed, string $expec self::assertSame($expectedNumber, (string) $number); } - public function providerFromBytes() : Generator + public static function providerFromBytes() : Generator { - foreach ($this->providerToBytes() as [$expectedNumber, $signed, $byteStringHex]) { + foreach (self::providerToBytes() as [$expectedNumber, $signed, $byteStringHex]) { yield [$byteStringHex, $signed, $expectedNumber]; // test with extra leading bits: these should return the same number @@ -3398,7 +3398,7 @@ public function testToBytes(string $number, bool $signed, string $expectedByteSt self::assertSame($expectedByteStringHex, strtoupper(bin2hex($byteString))); } - public function providerToBytes() : array + public static function providerToBytes() : array { return [ ['-549755813889', true, 'FF7FFFFFFFFF'], @@ -3617,7 +3617,7 @@ public function testRandomBits(int $numBits, string $randomBytesHex, string $exp self::assertBigIntegerEquals($expectedNumber, $actualNumber); } - public function providerRandomBits() : array + public static function providerRandomBits() : array { return [ [1, '00', '0'], @@ -3707,7 +3707,7 @@ public function testRandomRange(string $min, string $max, array $randomBytesHex, self::assertBigIntegerEquals($expectedNumber, $actualNumber); } - public function providerRandomRange() : array + public static function providerRandomRange() : array { return [ ['0', '1', ['00'], '0'], diff --git a/tests/BigNumberTest.php b/tests/BigNumberTest.php index efb6b67..b7b9656 100644 --- a/tests/BigNumberTest.php +++ b/tests/BigNumberTest.php @@ -32,7 +32,7 @@ public function testSum(array $values, string $expectedClass, string $expectedSu self::assertSame($expectedSum, (string) $sum); } - public function providerSum() : array + public static function providerSum() : array { return [ [[-1], BigInteger::class, '-1'], diff --git a/tests/BigRationalTest.php b/tests/BigRationalTest.php index 5ebb0c1..9b045e7 100644 --- a/tests/BigRationalTest.php +++ b/tests/BigRationalTest.php @@ -31,7 +31,7 @@ public function testNd(string $numerator, string $denominator, $n, $d) : void self::assertBigRationalInternalValues($numerator, $denominator, $rational); } - public function providerNd() : array + public static function providerNd() : array { return [ ['7', '1', '7', 1], @@ -61,7 +61,7 @@ public function testOf(string $numerator, string $denominator, string $string) : self::assertBigRationalInternalValues($numerator, $denominator, $rational); } - public function providerOf() : array + public static function providerOf() : array { return [ ['123', '456', '123/456'], @@ -93,7 +93,7 @@ public function testOfInvalidString(string $string) : void BigRational::of($string); } - public function providerOfInvalidString() : array + public static function providerOfInvalidString() : array { return [ ['123/-456'], @@ -145,7 +145,7 @@ public function testMin(array $values, string $min) : void self::assertBigRationalEquals($min, BigRational::min(... $values)); } - public function providerMin() : array + public static function providerMin() : array { return [ [['1/2', '1/4', '1/3'], '1/4'], @@ -172,7 +172,7 @@ public function testMax(array $values, string $max) : void self::assertBigRationalEquals($max, BigRational::max(... $values)); } - public function providerMax() : array + public static function providerMax() : array { return [ [['-5532146515641651651321321064580/32453', '-1/2', '-1/99'], '-1/99'], @@ -202,7 +202,7 @@ public function testSum(array $values, string $sum) : void self::assertBigRationalEquals($sum, BigRational::sum(... $values)); } - public function providerSum() : array + public static function providerSum() : array { return [ [['-5532146515641651651321321064580/32453', '-1/2', '-1/99'], '-1095365010097047026961621574064593/6425694'], @@ -241,7 +241,7 @@ public function testQuotientAndRemainder($rational, string $quotient, string $re self::assertBigIntegerEquals($remainder, $quotientAndRemainder[1]); } - public function providerQuotientAndRemainder() : array + public static function providerQuotientAndRemainder() : array { return [ ['1000/3', '333', '1'], @@ -263,7 +263,7 @@ public function testPlus(string $rational, $plus, string $expected) : void self::assertBigRationalEquals($expected, BigRational::of($rational)->plus($plus)); } - public function providerPlus() : array + public static function providerPlus() : array { return [ ['123/456', 1, '579/456'], @@ -288,7 +288,7 @@ public function testMinus(string $rational, string $minus, string $expected) : v self::assertBigRationalEquals($expected, BigRational::of($rational)->minus($minus)); } - public function providerMinus() : array + public static function providerMinus() : array { return [ ['123/456', '1', '-333/456'], @@ -311,7 +311,7 @@ public function testMultipliedBy(string $rational, string $minus, string $expect self::assertBigRationalEquals($expected, BigRational::of($rational)->multipliedBy($minus)); } - public function providerMultipliedBy() : array + public static function providerMultipliedBy() : array { return [ ['123/456', '1', '123/456'], @@ -336,7 +336,7 @@ public function testDividedBy(string $rational, string $minus, string $expected) self::assertBigRationalEquals($expected, BigRational::of($rational)->dividedBy($minus)); } - public function providerDividedBy() : array + public static function providerDividedBy() : array { return [ ['123/456', '1', '123/456'], @@ -361,7 +361,7 @@ public function testPower(string $number, int $exponent, string $expected) : voi self::assertBigRationalEquals($expected, BigRational::of($number)->power($exponent)); } - public function providerPower() : array + public static function providerPower() : array { return [ ['-3', 0, '1'], @@ -421,7 +421,7 @@ public function testReciprocal(string $rational, string $expected) : void self::assertBigRationalEquals($expected, BigRational::of($rational)->reciprocal()); } - public function providerReciprocal() : array + public static function providerReciprocal() : array { return [ ['1', '1'], @@ -450,7 +450,7 @@ public function testAbs(string $rational, string $expected) : void self::assertBigRationalEquals($expected, BigRational::of($rational)->abs()); } - public function providerAbs() : array + public static function providerAbs() : array { return [ ['0', '0'], @@ -473,7 +473,7 @@ public function testNegated(string $rational, string $expected) : void self::assertBigRationalEquals($expected, BigRational::of($rational)->negated()); } - public function providerNegated() : array + public static function providerNegated() : array { return [ ['0', '0'], @@ -497,7 +497,7 @@ public function testSimplified(string $rational, string $expected) : void self::assertBigRationalEquals($expected, BigRational::of($rational)->simplified()); } - public function providerSimplified() : array + public static function providerSimplified() : array { return [ ['0', '0'], @@ -588,7 +588,7 @@ public function testIsGreaterThanOrEqualTo(string $a, $b, int $cmp) : void self::assertSame($cmp >= 0, BigRational::of($a)->isGreaterThanOrEqualTo($b)); } - public function providerCompareTo() : array + public static function providerCompareTo() : array { return [ ['-1', '1/2', -1], @@ -685,7 +685,7 @@ public function testIsPositiveOrZero(string $number, int $sign) : void self::assertSame($sign >= 0, BigRational::of($number)->isPositiveOrZero()); } - public function providerSign() : array + public static function providerSign() : array { return [ ['0', 0], @@ -718,7 +718,7 @@ public function testToBigDecimal(string $number, ?string $expected) : void } } - public function providerToBigDecimal() : \Generator + public static function providerToBigDecimal() : \Generator { $tests = [ ['1', '1'], @@ -831,7 +831,7 @@ public function testToScale(string $number, int $scale, int $roundingMode, strin } } - public function providerToScale() : array + public static function providerToScale() : array { return [ ['1/8', 3, RoundingMode::UNNECESSARY, '0.125'], @@ -855,7 +855,7 @@ public function testToInt($rational, int $integer) : void self::assertSame($integer, BigRational::of($rational)->toInt()); } - public function providerToInt() : array + public static function providerToInt() : array { return [ [PHP_INT_MAX, PHP_INT_MAX], @@ -882,7 +882,7 @@ public function testToIntThrowsException(string $number) : void BigRational::of($number)->toInt(); } - public function providerToIntThrowsException() : array + public static function providerToIntThrowsException() : array { return [ ['-999999999999999999999999999999'], @@ -935,7 +935,7 @@ public function testToFloat(string $value, float $float) : void self::assertSame($float, BigRational::of($value)->toFloat()); } - public function providerToFloat() : array + public static function providerToFloat() : array { return [ ['0', 0.0], @@ -960,7 +960,7 @@ public function testToString(string $numerator, string $denominator, string $exp self::assertBigRationalEquals($expected, BigRational::nd($numerator, $denominator)); } - public function providerToString() : array + public static function providerToString() : array { return [ ['-1', '1', '-1'], diff --git a/tests/Internal/Calculator/NativeCalculatorTest.php b/tests/Internal/Calculator/NativeCalculatorTest.php index 245bdaa..da66764 100644 --- a/tests/Internal/Calculator/NativeCalculatorTest.php +++ b/tests/Internal/Calculator/NativeCalculatorTest.php @@ -21,7 +21,7 @@ public function testAdd(string $a, string $b, string $expectedValue) : void self::assertSame($expectedValue, $nativeCalculator->add($a, $b)); } - public function providerAdd() : array + public static function providerAdd() : array { return [ ['0', '1234567891234567889999999', '1234567891234567889999999'], @@ -43,7 +43,7 @@ public function testMul(string $a, string $b, string $expectedValue) : void self::assertSame($expectedValue, $nativeCalculator->mul($a, $b)); } - public function providerMul() : array + public static function providerMul() : array { return [ ['0', '0', '0'], @@ -70,7 +70,7 @@ public function testPow(string $a, int $b, string $expectedValue) : void self::assertSame($expectedValue, $nativeCalculator->pow($a, $b)); } - public function providerPow() : array + public static function providerPow() : array { return [ ['123456789012345678901234567890', 0, '1'],