From 0b7551994799d688da27e2cfbfebff53b676136f Mon Sep 17 00:00:00 2001 From: Jens True Date: Mon, 9 Mar 2026 11:44:13 +0000 Subject: [PATCH] Bit foies for static code analysis. --- .phive/phars.xml | 4 +- composer.lock | 8 +- psalm-baseline.xml | 288 ++++++++++++++++++ psalm.xml | 3 +- src/FactorGraphs/Variable.php | 4 +- .../FactorGraphTrueSkillCalculator.php | 6 - .../TwoPlayerTrueSkillCalculator.php | 12 +- src/TrueSkill/TwoTeamTrueSkillCalculator.php | 9 +- 8 files changed, 305 insertions(+), 29 deletions(-) create mode 100644 psalm-baseline.xml diff --git a/.phive/phars.xml b/.phive/phars.xml index 9c96bb7..6b6a9bc 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,12 +1,12 @@ - + - + diff --git a/composer.lock b/composer.lock index c729797..fdc9e22 100644 --- a/composer.lock +++ b/composer.lock @@ -456,11 +456,11 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.32", + "version": "1.12.33", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8", - "reference": "2770dcdf5078d0b0d53f94317e06affe88419aa8", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", + "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", "shasum": "" }, "require": { @@ -505,7 +505,7 @@ "type": "github" } ], - "time": "2025-09-30T10:16:31+00:00" + "time": "2026-02-28T20:30:03+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..1ec2ea5 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + playerToRating->getValue($player)]]> + + + playerToRating->getAllKeys()]]> + playerToRating->getAllValues()]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + varIndexOrdersForWeights]]> + + + + + + + + + + + getOutputVariablesGroups()]]> + + + + + getOutputVariablesGroups()]]> + + + + + + + + getOutputVariablesGroups()]]> + + + + + getOutputVariablesGroups()]]> + + + + + + + + + + + + + + + + + + getId()]]]> + getId()]]]> + + + diff --git a/psalm.xml b/psalm.xml index 6c46721..76c5516 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,12 +1,13 @@ diff --git a/src/FactorGraphs/Variable.php b/src/FactorGraphs/Variable.php index 1185d8c..5998c21 100644 --- a/src/FactorGraphs/Variable.php +++ b/src/FactorGraphs/Variable.php @@ -8,11 +8,11 @@ use DNW\Skills\Numerics\GaussianDistribution; class Variable { - private mixed $value; + private GaussianDistribution $value; public function __construct(private readonly GaussianDistribution $prior) { - $this->resetToPrior(); + $this->value = $prior; } public function getValue(): GaussianDistribution diff --git a/src/TrueSkill/FactorGraphTrueSkillCalculator.php b/src/TrueSkill/FactorGraphTrueSkillCalculator.php index a67c2c7..27dad73 100644 --- a/src/TrueSkill/FactorGraphTrueSkillCalculator.php +++ b/src/TrueSkill/FactorGraphTrueSkillCalculator.php @@ -29,9 +29,6 @@ final class FactorGraphTrueSkillCalculator extends SkillCalculator parent::__construct(SkillCalculator::PARTIAL_PLAY | SkillCalculator::PARTIAL_UPDATE, TeamsRange::atLeast(2), PlayersRange::atLeast(1)); } - /** - * {@inheritdoc} - */ #[\Override] public function calculateNewRatings( GameInfo $gameInfo, @@ -52,9 +49,6 @@ final class FactorGraphTrueSkillCalculator extends SkillCalculator return $factorGraph->getUpdatedRatings(); } - /** - * {@inheritdoc} - */ #[\Override] public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float { diff --git a/src/TrueSkill/TwoPlayerTrueSkillCalculator.php b/src/TrueSkill/TwoPlayerTrueSkillCalculator.php index 4bf0e24..e105642 100644 --- a/src/TrueSkill/TwoPlayerTrueSkillCalculator.php +++ b/src/TrueSkill/TwoPlayerTrueSkillCalculator.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace DNW\Skills\TrueSkill; use DNW\Skills\GameInfo; -use DNW\Skills\Guard; +use DNW\Skills\Team; use DNW\Skills\Numerics\BasicMath; use DNW\Skills\PairwiseComparison; use DNW\Skills\PlayersRange; @@ -28,9 +28,6 @@ final class TwoPlayerTrueSkillCalculator extends SkillCalculator parent::__construct(SkillCalculator::NONE, TeamsRange::exactly(2), PlayersRange::exactly(1)); } - /** - * {@inheritdoc} - */ #[\Override] public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer { @@ -39,7 +36,9 @@ final class TwoPlayerTrueSkillCalculator extends SkillCalculator // Make sure things are in order RankSorter::sort($teams, $teamRanks); - + /** + * @var Team[] $teams + */ // Since we verified that each team has one player, we know the player is the first one $winningTeamPlayers = $teams[0]->getAllPlayers(); $winner = $winningTeamPlayers[0]; @@ -132,9 +131,6 @@ final class TwoPlayerTrueSkillCalculator extends SkillCalculator return new Rating($newMean, $newStdDev); } - /** - * {@inheritdoc} - */ #[\Override] public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float { diff --git a/src/TrueSkill/TwoTeamTrueSkillCalculator.php b/src/TrueSkill/TwoTeamTrueSkillCalculator.php index 5356d2f..bb8fdad 100644 --- a/src/TrueSkill/TwoTeamTrueSkillCalculator.php +++ b/src/TrueSkill/TwoTeamTrueSkillCalculator.php @@ -28,9 +28,6 @@ final class TwoTeamTrueSkillCalculator extends SkillCalculator parent::__construct(SkillCalculator::NONE, TeamsRange::exactly(2), PlayersRange::atLeast(1)); } - /** - * {@inheritdoc} - */ #[\Override] public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer { @@ -38,6 +35,9 @@ final class TwoTeamTrueSkillCalculator extends SkillCalculator RankSorter::sort($teams, $teamRanks); + /** + * @var Team[] $teams + */ $team1 = $teams[0]; $team2 = $teams[1]; @@ -138,9 +138,6 @@ final class TwoTeamTrueSkillCalculator extends SkillCalculator } } - /** - * {@inheritdoc} - */ #[\Override] public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float {