Refactoring for PHP8.2

This commit is contained in:
Jens True 2023-08-01 11:26:38 +00:00
parent 5dd4acf57d
commit 068b6f18aa
18 changed files with 375 additions and 782 deletions

4
.gitignore vendored

@ -1,6 +1,8 @@
coverage
nbproject
.idea
.vscode
vendor
bin
.phpunit.result.cache
.phpunit.cache
composer.phar

@ -6,10 +6,10 @@
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"rector/rector": "^0.13.7",
"phpstan/phpstan": "^1.8",
"laravel/pint": "^0.2.3"
"phpunit/phpunit": "^10",
"rector/rector": "^0.17",
"phpstan/phpstan": "^1",
"laravel/pint": "^1"
},
"autoload": {
"psr-4": {

989
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -2,4 +2,6 @@ parameters:
level: 6
paths:
- src
- tests
# - tests
ignoreErrors:
- '#with no value type specified in iterable type array#'

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="PHPSkills Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>

@ -11,21 +11,21 @@ use Exception;
*/
class Guard
{
public static function argumentNotNull($value, $parameterName)
public static function argumentNotNull(mixed $value, string $parameterName): void
{
if ($value == null) {
throw new Exception($parameterName.' can not be null');
}
}
public static function argumentIsValidIndex($index, $count, $parameterName)
public static function argumentIsValidIndex(int $index, int $count, string $parameterName): void
{
if (($index < 0) || ($index >= $count)) {
throw new Exception($parameterName.' is an invalid index');
}
}
public static function argumentInRangeInclusive($value, $min, $max, $parameterName)
public static function argumentInRangeInclusive(float $value, float $min, float $max, string $parameterName): void
{
if (($value < $min) || ($value > $max)) {
throw new Exception($parameterName.' is not in the valid range ['.$min.', '.$max.']');

@ -7,20 +7,11 @@ namespace DNW\Skills;
*
* @internal The actual values for the enum were chosen so that the also correspond to the multiplier for updates to means.
*/
class PairwiseComparison
enum PairwiseComparison: int
{
final const WIN = 1;
case WIN = 1;
final const DRAW = 0;
case DRAW = 0;
final const LOSE = -1;
public static function getRankFromComparison($comparison)
{
return match ($comparison) {
PairwiseComparison::WIN => [1, 2],
PairwiseComparison::LOSE => [2, 1],
default => [1, 1],
};
}
case LOSE = -1;
}

@ -18,7 +18,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
parent::__construct($parentGraph);
}
public function getLocalFactors()
public function getLocalFactors(): array
{
return array_merge($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors(),
$this->_TeamDifferencesComparisonLayer->getLocalFactors()
@ -36,7 +36,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
$this->_TeamDifferencesComparisonLayer->buildLayer();
}
public function createPriorSchedule()
public function createPriorSchedule(): ScheduleSequence
{
switch (is_countable($this->getInputVariablesGroups()) ? count($this->getInputVariablesGroups()) : 0) {
case 0:

@ -102,7 +102,7 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
// non-draw case
$v = TruncatedGaussianCorrectionFunctions::vExceedsMarginScaled($meanDelta, $drawMargin, $c);
$w = TruncatedGaussianCorrectionFunctions::wExceedsMarginScaled($meanDelta, $drawMargin, $c);
$rankMultiplier = (int) $comparison;
$rankMultiplier = $comparison->value;
} else {
$v = TruncatedGaussianCorrectionFunctions::vWithinMarginScaled($meanDelta, $drawMargin, $c);
$w = TruncatedGaussianCorrectionFunctions::wWithinMarginScaled($meanDelta, $drawMargin, $c);

@ -27,7 +27,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
parent::__construct(SkillCalculatorSupportedOptions::NONE, TeamsRange::exactly(2), PlayersRange::atLeast(1));
}
public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks)
public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer
{
Guard::argumentNotNull($gameInfo, 'gameInfo');
$this->validateTeamCountAndPlayersCountPerTeam($teams);
@ -60,7 +60,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
RatingContainer $newPlayerRatings,
Team $selfTeam,
Team $otherTeam,
$selfToOtherTeamComparison)
PairwiseComparison $selfToOtherTeamComparison): void
{
$drawMargin = DrawMargin::getDrawMarginFromDrawProbability(
$gameInfo->getDrawProbability(),
@ -107,7 +107,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
// non-draw case
$v = TruncatedGaussianCorrectionFunctions::vExceedsMarginScaled($meanDelta, $drawMargin, $c);
$w = TruncatedGaussianCorrectionFunctions::wExceedsMarginScaled($meanDelta, $drawMargin, $c);
$rankMultiplier = (int) $selfToOtherTeamComparison;
$rankMultiplier = $selfToOtherTeamComparison->value;
} else {
// assume draw
$v = TruncatedGaussianCorrectionFunctions::vWithinMarginScaled($meanDelta, $drawMargin, $c);
@ -137,7 +137,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
/**
* {@inheritdoc}
*/
public function calculateMatchQuality(GameInfo $gameInfo, array $teams)
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
{
Guard::argumentNotNull($gameInfo, 'gameInfo');
$this->validateTeamCountAndPlayersCountPerTeam($teams);

@ -7,7 +7,7 @@ use DNW\Skills\Tests\TestCase;
class BasicMathTest extends TestCase
{
public function testSquare()
public function testSquare(): void
{
$this->assertEquals(1, BasicMath::square(1));
$this->assertEquals(1.44, BasicMath::square(1.2));

@ -10,21 +10,21 @@ class GaussianDistributionTest extends TestCase
{
const ERROR_TOLERANCE = 0.000001;
public function testCumulativeTo()
public function testCumulativeTo(): void
{
// Verified with WolframAlpha
// (e.g. http://www.wolframalpha.com/input/?i=CDF%5BNormalDistribution%5B0%2C1%5D%2C+0.5%5D )
$this->assertEqualsWithDelta(0.691462, GaussianDistribution::cumulativeTo(0.5), GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testAt()
public function testAt(): void
{
// Verified with WolframAlpha
// (e.g. http://www.wolframalpha.com/input/?i=PDF%5BNormalDistribution%5B0%2C1%5D%2C+0.5%5D )
$this->assertEqualsWithDelta(0.352065, GaussianDistribution::at(0.5), GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testMultiplication()
public function testMultiplication(): void
{
// I verified this against the formula at http://www.tina-vision.net/tina-knoppix/tina-memo/2003-003.pdf
$standardNormal = new GaussianDistribution(0, 1);
@ -46,7 +46,7 @@ class GaussianDistributionTest extends TestCase
$this->assertEqualsWithDelta($expectedSigma, $product2->getStandardDeviation(), GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testDivision()
public function testDivision(): void
{
// Since the multiplication was worked out by hand, we use the same numbers but work backwards
$product = new GaussianDistribution(0.2, 3.0 / sqrt(10));
@ -63,7 +63,7 @@ class GaussianDistributionTest extends TestCase
$this->assertEqualsWithDelta(7.0, $product2DividedByM4S5->getStandardDeviation(), GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testLogProductNormalization()
public function testLogProductNormalization(): void
{
// Verified with Ralf Herbrich's F# implementation
$standardNormal = new GaussianDistribution(0, 1);
@ -76,7 +76,7 @@ class GaussianDistributionTest extends TestCase
$this->assertEqualsWithDelta(-2.5168046699816684, $lpn2, GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testLogRatioNormalization()
public function testLogRatioNormalization(): void
{
// Verified with Ralf Herbrich's F# implementation
$m1s2 = new GaussianDistribution(1, 2);
@ -85,7 +85,7 @@ class GaussianDistributionTest extends TestCase
$this->assertEqualsWithDelta(2.6157405972171204, $lrn, GaussianDistributionTest::ERROR_TOLERANCE);
}
public function testAbsoluteDifference()
public function testAbsoluteDifference(): void
{
// Verified with Ralf Herbrich's F# implementation
$standardNormal = new GaussianDistribution(0, 1);

@ -9,7 +9,7 @@ use DNW\Skills\Tests\TestCase;
class MatrixTest extends TestCase
{
public function testTwoByTwoDeterminant()
public function testTwoByTwoDeterminant(): void
{
$a = new SquareMatrix(1, 2,
3, 4);
@ -32,7 +32,7 @@ class MatrixTest extends TestCase
$this->assertEquals(12 * 21 - 15 * 17, $d->getDeterminant());
}
public function testThreeByThreeDeterminant()
public function testThreeByThreeDeterminant(): void
{
$a = new SquareMatrix(1, 2, 3,
4, 5, 6,
@ -48,7 +48,7 @@ class MatrixTest extends TestCase
$this->assertEquals(-90, $pi->getDeterminant());
}
public function testFourByFourDeterminant()
public function testFourByFourDeterminant(): void
{
$a = new SquareMatrix(1, 2, 3, 4,
5, 6, 7, 8,
@ -66,7 +66,7 @@ class MatrixTest extends TestCase
$this->assertEquals(98, $pi->getDeterminant());
}
public function testEightByEightDeterminant()
public function testEightByEightDeterminant(): void
{
$a = new SquareMatrix(1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
@ -92,7 +92,7 @@ class MatrixTest extends TestCase
$this->assertEquals(1378143, $pi->getDeterminant());
}
public function testEquals()
public function testEquals(): void
{
$a = new SquareMatrix(1, 2,
3, 4);
@ -130,7 +130,7 @@ class MatrixTest extends TestCase
$this->assertTrue($g->equals($h));
}
public function testAdjugate()
public function testAdjugate(): void
{
// From Wikipedia: http://en.wikipedia.org/wiki/Adjugate_matrix
$a = new SquareMatrix(1, 2,
@ -152,7 +152,7 @@ class MatrixTest extends TestCase
$this->assertTrue($d->equals($c->getAdjugate()));
}
public function testInverse()
public function testInverse(): void
{
// see http://www.mathwords.com/i/inverse_of_a_matrix.htm
$a = new SquareMatrix(4, 3,

@ -9,7 +9,7 @@ class DrawMarginTest extends TestCase
{
const ERROR_TOLERANCE = 0.000001;
public function testGetDrawMarginFromDrawProbability()
public function testGetDrawMarginFromDrawProbability(): void
{
$beta = 25.0 / 6.0;
// The expected values were compared against Ralf Herbrich's implementation in F#
@ -18,7 +18,7 @@ class DrawMarginTest extends TestCase
$this->assertDrawMargin(0.33, $beta, 2.5111010132487492);
}
private function assertDrawMargin($drawProbability, $beta, $expected)
private function assertDrawMargin($drawProbability, $beta, $expected): void
{
$actual = DrawMargin::getDrawMarginFromDrawProbability($drawProbability, $beta);
$this->assertEqualsWithDelta($expected, $actual, DrawMarginTest::ERROR_TOLERANCE);

@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
class FactorGraphTeamTrueSkillCalculatorTest extends TestCase
{
public function testFactorGraphTrueSkillCalculator()
public function testFactorGraphTrueSkillCalculator(): void
{
$calculator = new FactorGraphTrueSkillCalculator();

@ -18,7 +18,7 @@ class TrueSkillCalculatorTests
// These are the roll-up ones
public static function testAllTwoPlayerScenarios(TestCase $testClass, SkillCalculator $calculator)
public static function testAllTwoPlayerScenarios(TestCase $testClass, SkillCalculator $calculator): void
{
self::twoPlayerTestNotDrawn($testClass, $calculator);
self::twoPlayerTestDrawn($testClass, $calculator);
@ -26,7 +26,7 @@ class TrueSkillCalculatorTests
self::oneOnOneMassiveUpsetDrawTest($testClass, $calculator);
}
public static function testAllTwoTeamScenarios(TestCase $testClass, SkillCalculator $calculator)
public static function testAllTwoTeamScenarios(TestCase $testClass, SkillCalculator $calculator): void
{
self::oneOnTwoSimpleTest($testClass, $calculator);
self::oneOnTwoSomewhatBalanced($testClass, $calculator);
@ -45,7 +45,7 @@ class TrueSkillCalculatorTests
self::fourOnFourSimpleTest($testClass, $calculator);
}
public static function testAllMultipleTeamScenarios(TestCase $testClass, SkillCalculator $calculator)
public static function testAllMultipleTeamScenarios(TestCase $testClass, SkillCalculator $calculator): void
{
self::threeTeamsOfOneNotDrawn($testClass, $calculator);
self::threeTeamsOfOneDrawn($testClass, $calculator);
@ -57,7 +57,7 @@ class TrueSkillCalculatorTests
self::twoOnFourOnTwoWinDraw($testClass, $calculator);
}
public static function testPartialPlayScenarios(TestCase $testClass, SkillCalculator $calculator)
public static function testPartialPlayScenarios(TestCase $testClass, SkillCalculator $calculator): void
{
self::oneOnTwoBalancedPartialPlay($testClass, $calculator);
}
@ -76,7 +76,7 @@ class TrueSkillCalculatorTests
// Two Player Tests
//------------------------------------------------------------------------------
private static function twoPlayerTestNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function twoPlayerTestNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -97,7 +97,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function twoPlayerTestDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function twoPlayerTestDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -119,7 +119,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function twoPlayerChessTestNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function twoPlayerChessTestNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
// Inspired by a real bug :-)
$player1 = new Player(1);
@ -138,7 +138,7 @@ class TrueSkillCalculatorTests
self::assertRating($testClass, 1185.0383099003536, 42.485604606897752, $player2NewRating);
}
private static function oneOnOneMassiveUpsetDrawTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnOneMassiveUpsetDrawTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -167,7 +167,7 @@ class TrueSkillCalculatorTests
// Two Team Tests
//------------------------------------------------------------------------------
private static function oneOnTwoSimpleTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnTwoSimpleTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -200,7 +200,7 @@ class TrueSkillCalculatorTests
// Two Team Tests
//------------------------------------------------------------------------------
private static function twoOnTwoSimpleTest(TestCase $testClass, SkillCalculator $calculator)
private static function twoOnTwoSimpleTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -232,7 +232,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function oneOnTwoSomewhatBalanced(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnTwoSomewhatBalanced(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -261,7 +261,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.478, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function oneOnThreeSimpleTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnThreeSimpleTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -293,7 +293,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.012, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function oneOnTwoDrawTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnTwoDrawTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -322,7 +322,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.135, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function oneOnThreeDrawTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnThreeDrawTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -354,7 +354,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.012, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function oneOnSevenSimpleTest(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnSevenSimpleTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
@ -398,7 +398,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.000, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function threeOnTwoTests(TestCase $testClass, SkillCalculator $calculator)
private static function threeOnTwoTests(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -444,7 +444,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.254, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function twoOnTwoUnbalancedDrawTest(TestCase $testClass, SkillCalculator $calculator)
private static function twoOnTwoUnbalancedDrawTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -476,7 +476,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.214, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function twoOnTwoUpsetTest(TestCase $testClass, SkillCalculator $calculator)
private static function twoOnTwoUpsetTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -508,7 +508,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.084, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function fourOnFourSimpleTest(TestCase $testClass, SkillCalculator $calculator)
private static function fourOnFourSimpleTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -553,7 +553,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function twoOnTwoDrawTest(TestCase $testClass, SkillCalculator $calculator)
private static function twoOnTwoDrawTest(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -585,7 +585,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.447, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function threeTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function threeTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -612,7 +612,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.200, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function threeTeamsOfOneDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function threeTeamsOfOneDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -639,7 +639,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.200, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function fourTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function fourTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -671,7 +671,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.089, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function fiveTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function fiveTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -707,7 +707,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.040, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function eightTeamsOfOneDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function eightTeamsOfOneDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -758,7 +758,7 @@ class TrueSkillCalculatorTests
self::AssertMatchQuality($testClass, 0.004, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function eightTeamsOfOneUpset(TestCase $testClass, SkillCalculator $calculator)
private static function eightTeamsOfOneUpset(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -810,7 +810,7 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.000, $calculator->calculateMatchQuality($gameInfo, $teams));
}
private static function sixteenTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator)
private static function sixteenTeamsOfOneNotDrawn(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -907,7 +907,7 @@ class TrueSkillCalculatorTests
self::assertRating($testClass, 9.46054223053080, 5.27581643889032, $player16NewRating);
}
private static function twoOnFourOnTwoWinDraw(TestCase $testClass, SkillCalculator $calculator)
private static function twoOnFourOnTwoWinDraw(TestCase $testClass, SkillCalculator $calculator): void
{
$player1 = new Player(1);
$player2 = new Player(2);
@ -956,7 +956,7 @@ class TrueSkillCalculatorTests
// Partial Play Tests
//------------------------------------------------------------------------------
private static function oneOnTwoBalancedPartialPlay(TestCase $testClass, SkillCalculator $calculator)
private static function oneOnTwoBalancedPartialPlay(TestCase $testClass, SkillCalculator $calculator): void
{
$gameInfo = new GameInfo();
@ -986,13 +986,13 @@ class TrueSkillCalculatorTests
self::assertMatchQuality($testClass, 0.44721358745011336, $matchQuality);
}
private static function assertRating(TestCase $testClass, $expectedMean, $expectedStandardDeviation, $actual)
private static function assertRating(TestCase $testClass, $expectedMean, $expectedStandardDeviation, $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)
private static function assertMatchQuality(TestCase $testClass, $expectedMatchQuality, $actualMatchQuality): void
{
$testClass->assertEqualsWithDelta($expectedMatchQuality, $actualMatchQuality, self::ERROR_TOLERANCE_MATCH_QUALITY);
}

@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\TwoPlayerTrueSkillCalculator;
class TwoPlayerTrueSkillCalculatorTest extends TestCase
{
public function testTwoPlayerTrueSkillCalculator()
public function testTwoPlayerTrueSkillCalculator(): void
{
$calculator = new TwoPlayerTrueSkillCalculator();

@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\TwoTeamTrueSkillCalculator;
class TwoTeamTrueSkillCalculatorTest extends TestCase
{
public function testTwoTeamTrueSkillCalculator()
public function testTwoTeamTrueSkillCalculator(): void
{
$calculator = new TwoTeamTrueSkillCalculator();