mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-19 12:24:28 +00:00
Much stricter coding standards for phpstan, phpstan and psalm.
This commit is contained in:
@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(BasicMath::class)]
|
||||
class BasicMathTest extends TestCase
|
||||
final class BasicMathTest extends TestCase
|
||||
{
|
||||
public function testSquare(): void
|
||||
{
|
||||
@ -23,7 +23,7 @@ class BasicMathTest extends TestCase
|
||||
$arr = [1, 1, 1, 1];
|
||||
|
||||
$func_return = static fn(float $f): float => $f;
|
||||
$func_double = static fn(float $f): float => $f * 2;
|
||||
$func_double = static fn(float $f): float => $f * 2.0;
|
||||
$this->assertEquals(4, BasicMath::sum($arr, $func_return));
|
||||
$this->assertEquals(8, BasicMath::sum($arr, $func_double));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
|
||||
|
||||
#[CoversClass(GaussianDistribution::class)]
|
||||
#[UsesClass(BasicMath::class)]
|
||||
class GaussianDistributionTest extends TestCase
|
||||
final class GaussianDistributionTest extends TestCase
|
||||
{
|
||||
private const float ERROR_TOLERANCE = 0.000001;
|
||||
|
||||
@ -24,7 +24,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEquals(9, $gd->getVariance());
|
||||
$this->assertEquals(3, $gd->getStandardDeviation());
|
||||
$this->assertEquals(1 / 9, $gd->getPrecision());
|
||||
$this->assertEquals(1 / 9 * 10, $gd->getPrecisionMean());
|
||||
$this->assertEquals(1.0 / 9.0 * 10.0, $gd->getPrecisionMean());
|
||||
$this->assertEqualsWithDelta(0.13298076013, $gd->getNormalizationConstant(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class GaussianDistributionTest extends TestCase
|
||||
|
||||
$product2 = GaussianDistribution::multiply($m4s5, $m6s7);
|
||||
|
||||
$expectedMean = (4 * BasicMath::square(7) + 6 * BasicMath::square(5)) / (BasicMath::square(5) + BasicMath::square(7));
|
||||
$expectedMean = (4.0 * BasicMath::square(7) + 6.0 * BasicMath::square(5)) / (BasicMath::square(5) + BasicMath::square(7));
|
||||
$this->assertEqualsWithDelta($expectedMean, $product2->getMean(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
|
||||
$expectedSigma = sqrt(((BasicMath::square(5) * BasicMath::square(7)) / (BasicMath::square(5) + BasicMath::square(7))));
|
||||
@ -74,7 +74,7 @@ class GaussianDistributionTest extends TestCase
|
||||
$this->assertEqualsWithDelta(2.0, $productDividedByStandardNormal->getMean(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
$this->assertEqualsWithDelta(3.0, $productDividedByStandardNormal->getStandardDeviation(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
|
||||
$product2 = new GaussianDistribution((4 * BasicMath::square(7) + 6 * BasicMath::square(5)) / (BasicMath::square(5) + BasicMath::square(7)), sqrt(((BasicMath::square(5) * BasicMath::square(7)) / (BasicMath::square(5) + BasicMath::square(7)))));
|
||||
$product2 = new GaussianDistribution((4.0 * BasicMath::square(7) + 6.0 * BasicMath::square(5)) / (BasicMath::square(5) + BasicMath::square(7)), sqrt(((BasicMath::square(5) * BasicMath::square(7)) / (BasicMath::square(5) + BasicMath::square(7)))));
|
||||
$m4s5 = new GaussianDistribution(4, 5);
|
||||
$product2DividedByM4S5 = GaussianDistribution::divide($product2, $m4s5);
|
||||
$this->assertEqualsWithDelta(6.0, $product2DividedByM4S5->getMean(), GaussianDistributionTest::ERROR_TOLERANCE);
|
||||
|
@ -20,7 +20,7 @@ use Exception;
|
||||
#[CoversClass(DiagonalMatrix::class)]
|
||||
#[CoversClass(Vector::class)]
|
||||
// phpcs:disable PSR2.Methods.FunctionCallSignature,Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma
|
||||
class MatrixTest extends TestCase
|
||||
final class MatrixTest extends TestCase
|
||||
{
|
||||
public function testEmptyMatrix(): void
|
||||
{
|
||||
@ -295,7 +295,7 @@ class MatrixTest extends TestCase
|
||||
1, 0, 6);
|
||||
|
||||
$cInverse = $c->getInverse();
|
||||
$d = Matrix::scalarMultiply((1.0 / 22), new SquareMatrix(24, -12, -2,
|
||||
$d = Matrix::scalarMultiply((1.0 / 22.0), new SquareMatrix(24, -12, -2,
|
||||
5, 3, -5,
|
||||
-4, 2, 4));
|
||||
|
||||
|
@ -10,7 +10,7 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use Exception;
|
||||
|
||||
#[CoversClass(Range::class)]
|
||||
class RangeTest extends TestCase
|
||||
final class RangeTest extends TestCase
|
||||
{
|
||||
public function testConstructInvalidParam(): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user