From 9acc3bbeabb26c69a027b9b177e7a2864f931895 Mon Sep 17 00:00:00 2001 From: Jens True Date: Fri, 4 Aug 2023 07:03:28 +0000 Subject: [PATCH] PHPstan on test code --- composer.json | 2 +- phpstan.neon | 2 +- tests/RankSorterTest.php | 2 +- tests/TrueSkill/DrawMarginTest.php | 2 +- tests/TrueSkill/TrueSkillCalculatorTests.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 8b65249..851f56f 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "@analyze-phpcs", "@analyze-psalm" ], - "analyze-phpstan":"vendor/bin/phpstan analyze --error-format=raw src/", + "analyze-phpstan":"vendor/bin/phpstan analyze --error-format=raw", "analyze-phpcs": "vendor/bin/phpcs --report=emacs --standard=PSR12 --exclude=Generic.Files.LineLength src", "analyze-psalm": "vendor/bin/psalm" } diff --git a/phpstan.neon b/phpstan.neon index 9aad0db..54e6f5d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,4 +2,4 @@ parameters: level: 6 paths: - src -# - tests + - tests diff --git a/tests/RankSorterTest.php b/tests/RankSorterTest.php index 6044857..07776f1 100644 --- a/tests/RankSorterTest.php +++ b/tests/RankSorterTest.php @@ -6,7 +6,7 @@ use DNW\Skills\RankSorter; class RankSorterTest extends TestCase { - public function testSort() + public function testSort(): void { $team1 = ['a' => 1, 'b' => 2]; $team2 = ['c' => 3, 'd' => 4]; diff --git a/tests/TrueSkill/DrawMarginTest.php b/tests/TrueSkill/DrawMarginTest.php index b84a19b..ae773ce 100644 --- a/tests/TrueSkill/DrawMarginTest.php +++ b/tests/TrueSkill/DrawMarginTest.php @@ -18,7 +18,7 @@ class DrawMarginTest extends TestCase $this->assertDrawMargin(0.33, $beta, 2.5111010132487492); } - private function assertDrawMargin($drawProbability, $beta, $expected): void + private function assertDrawMargin(float $drawProbability, float $beta, float $expected): void { $actual = DrawMargin::getDrawMarginFromDrawProbability($drawProbability, $beta); $this->assertEqualsWithDelta($expected, $actual, DrawMarginTest::ERROR_TOLERANCE); diff --git a/tests/TrueSkill/TrueSkillCalculatorTests.php b/tests/TrueSkill/TrueSkillCalculatorTests.php index 9c845b9..3938ff5 100644 --- a/tests/TrueSkill/TrueSkillCalculatorTests.php +++ b/tests/TrueSkill/TrueSkillCalculatorTests.php @@ -986,13 +986,13 @@ class TrueSkillCalculatorTests self::assertMatchQuality($testClass, 0.44721358745011336, $matchQuality); } - private static function assertRating(TestCase $testClass, $expectedMean, $expectedStandardDeviation, $actual): void + private static function assertRating(TestCase $testClass, float $expectedMean, float $expectedStandardDeviation, Rating $actual): void { $testClass->assertEqualsWithDelta($expectedMean, $actual->getMean(), self::ERROR_TOLERANCE_TRUESKILL); $testClass->assertEqualsWithDelta($expectedStandardDeviation, $actual->getStandardDeviation(), self::ERROR_TOLERANCE_TRUESKILL); } - private static function assertMatchQuality(TestCase $testClass, $expectedMatchQuality, $actualMatchQuality): void + private static function assertMatchQuality(TestCase $testClass, float $expectedMatchQuality, float $actualMatchQuality): void { $testClass->assertEqualsWithDelta($expectedMatchQuality, $actualMatchQuality, self::ERROR_TOLERANCE_MATCH_QUALITY); }