diff --git a/composer.lock b/composer.lock index 0ccf7d9..8b48f2c 100644 --- a/composer.lock +++ b/composer.lock @@ -1280,16 +1280,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.58", + "version": "1.10.59", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "a23518379ec4defd9e47cbf81019526861623ec2" + "reference": "e607609388d3a6d418a50a49f7940e8086798281" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a23518379ec4defd9e47cbf81019526861623ec2", - "reference": "a23518379ec4defd9e47cbf81019526861623ec2", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e607609388d3a6d418a50a49f7940e8086798281", + "reference": "e607609388d3a6d418a50a49f7940e8086798281", "shasum": "" }, "require": { @@ -1338,7 +1338,7 @@ "type": "tidelift" } ], - "time": "2024-02-12T20:02:57+00:00" + "time": "2024-02-20T13:59:13+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/rector.php b/rector.php index 00c5a54..350fa51 100644 --- a/rector.php +++ b/rector.php @@ -14,6 +14,4 @@ return RectorConfig::configure() ]) // uncomment to reach your current PHP version ->withPhpSets() - ->withRules([ - AddVoidReturnTypeWhereNoReturnRector::class, - ]); + ->withPreparedSets(typeDeclarations : true); diff --git a/src/FactorGraphs/Factor.php b/src/FactorGraphs/Factor.php index a17dca4..841b584 100644 --- a/src/FactorGraphs/Factor.php +++ b/src/FactorGraphs/Factor.php @@ -31,9 +31,9 @@ abstract class Factor implements \Stringable } /** - * @return mixed The log-normalization constant of that factor + * @return float The log-normalization constant of that factor */ - public function getLogNormalization() + public function getLogNormalization(): float { return 0; } diff --git a/src/FactorGraphs/FactorGraphLayer.php b/src/FactorGraphs/FactorGraphLayer.php index 4e39789..5601ede 100644 --- a/src/FactorGraphs/FactorGraphLayer.php +++ b/src/FactorGraphs/FactorGraphLayer.php @@ -21,7 +21,7 @@ abstract class FactorGraphLayer /** * @var array> */ - private $inputVariablesGroups = []; + private array $inputVariablesGroups = []; protected function __construct(private readonly TrueSkillFactorGraph $parentFactorGraph) { diff --git a/src/TrueSkill/Factors/GaussianWeightedSumFactor.php b/src/TrueSkill/Factors/GaussianWeightedSumFactor.php index 51c64c5..6575eeb 100644 --- a/src/TrueSkill/Factors/GaussianWeightedSumFactor.php +++ b/src/TrueSkill/Factors/GaussianWeightedSumFactor.php @@ -125,7 +125,7 @@ class GaussianWeightedSumFactor extends GaussianFactor } } - public function getLogNormalization() + public function getLogNormalization(): float { $vars = $this->getVariables(); $messages = $this->getMessages(); diff --git a/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php b/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php index 5b08146..25887a2 100644 --- a/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php +++ b/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php @@ -37,7 +37,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye return $this->scheduleSequence( array_map( - fn ($weightedSumFactor) => new ScheduleStep('Perf to Team Perf Step', $weightedSumFactor, 0), + fn ($weightedSumFactor): ScheduleStep => new ScheduleStep('Perf to Team Perf Step', $weightedSumFactor, 0), $localFactors ), 'all player perf to team perf schedule' @@ -50,7 +50,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye protected function createPlayerToTeamSumFactor(array $teamMembers, Variable $sumVariable): GaussianWeightedSumFactor { $weights = array_map( - function ($v) { + function ($v): float { $player = $v->getKey(); return PartialPlay::getPartialPlayPercentage($player); @@ -89,7 +89,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye */ private function createOutputVariable(array $team): Variable { - $memberNames = array_map(fn ($currentPlayer) => (string)($currentPlayer->getKey()), $team); + $memberNames = array_map(fn ($currentPlayer): string => (string)($currentPlayer->getKey()), $team); $teamMemberNames = \implode(', ', $memberNames); diff --git a/src/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php b/src/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php index e359164..db72d43 100644 --- a/src/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php +++ b/src/TrueSkill/Layers/PlayerPriorValuesToSkillsLayer.php @@ -55,7 +55,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer return $this->scheduleSequence( array_map( - fn ($prior) => new ScheduleStep('Prior to Skill Step', $prior, 0), + fn ($prior): ScheduleStep => new ScheduleStep('Prior to Skill Step', $prior, 0), $localFactors ), 'All priors' diff --git a/src/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php b/src/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php index 525acde..80d66a9 100644 --- a/src/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php +++ b/src/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php @@ -53,7 +53,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer return $this->scheduleSequence( array_map( - fn ($likelihood) => new ScheduleStep('Skill to Perf step', $likelihood, 0), + fn ($likelihood): ScheduleStep => new ScheduleStep('Skill to Perf step', $likelihood, 0), $localFactors ), 'All skill to performance sending' @@ -66,7 +66,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer return $this->scheduleSequence( array_map( - fn ($likelihood) => new ScheduleStep('name', $likelihood, 1), + fn ($likelihood): ScheduleStep => new ScheduleStep('name', $likelihood, 1), $localFactors ), 'All skill to performance sending' diff --git a/src/TrueSkill/TrueSkillFactorGraph.php b/src/TrueSkill/TrueSkillFactorGraph.php index 2ddd63f..064303b 100644 --- a/src/TrueSkill/TrueSkillFactorGraph.php +++ b/src/TrueSkill/TrueSkillFactorGraph.php @@ -39,7 +39,7 @@ class TrueSkillFactorGraph extends FactorGraph { $this->priorLayer = new PlayerPriorValuesToSkillsLayer($this, $teams); $newFactory = new VariableFactory( - fn () => GaussianDistribution::fromPrecisionMean(0, 0) + fn (): GaussianDistribution => GaussianDistribution::fromPrecisionMean(0, 0) ); $this->setVariableFactory($newFactory);