mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-16 01:47:39 +00:00
More types for static analysis
This commit is contained in:
@ -60,14 +60,14 @@ abstract class FactorGraphLayer
|
|||||||
$this->localFactors[] = $factor;
|
$this->localFactors[] = $factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function buildLayer();
|
abstract public function buildLayer(): void;
|
||||||
|
|
||||||
public function createPriorSchedule()
|
public function createPriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPosteriorSchedule()
|
public function createPosteriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,9 @@ class RankSorter
|
|||||||
/**
|
/**
|
||||||
* Performs an in-place sort of the items in according to the ranks in non-decreasing order.
|
* Performs an in-place sort of the items in according to the ranks in non-decreasing order.
|
||||||
*
|
*
|
||||||
* @param array $teams The items to sort according to the order specified by ranks.
|
* @param array<mixed> $teams The items to sort according to the order specified by ranks.
|
||||||
* @param array $teamRanks The ranks for each item where 1 is first place.
|
* @param array<int> $teamRanks The ranks for each item where 1 is first place.
|
||||||
* @return array
|
* @return array<array>
|
||||||
*/
|
*/
|
||||||
public static function sort(array &$teams, array &$teamRanks): array
|
public static function sort(array &$teams, array &$teamRanks): array
|
||||||
{
|
{
|
||||||
|
@ -198,8 +198,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
|||||||
// The tricky part here is that we have to put the messages and variables in the same
|
// The tricky part here is that we have to put the messages and variables in the same
|
||||||
// order as the weights. Thankfully, the weights and messages share the same index numbers,
|
// order as the weights. Thankfully, the weights and messages share the same index numbers,
|
||||||
// so we just need to make sure they're consistent
|
// so we just need to make sure they're consistent
|
||||||
$allMessagesCount = is_countable($allMessages) ? count($allMessages) : 0;
|
for ($i = 0; $i < count($allMessages); $i++) {
|
||||||
for ($i = 0; $i < $allMessagesCount; $i++) {
|
|
||||||
$updatedMessages[] = $allMessages[$indicesToUse[$i]];
|
$updatedMessages[] = $allMessages[$indicesToUse[$i]];
|
||||||
$updatedVariables[] = $allVariables[$indicesToUse[$i]];
|
$updatedVariables[] = $allVariables[$indicesToUse[$i]];
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
|||||||
$this->TeamDifferencesComparisonLayer->buildLayer();
|
$this->TeamDifferencesComparisonLayer->buildLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPriorSchedule(): ScheduleSequence
|
public function createPriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
switch (is_countable($this->getInputVariablesGroups()) ? count($this->getInputVariablesGroups()) : 0) {
|
switch (is_countable($this->getInputVariablesGroups()) ? count($this->getInputVariablesGroups()) : 0) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -78,7 +78,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createTwoTeamInnerPriorLoopSchedule()
|
private function createTwoTeamInnerPriorLoopSchedule(): ScheduleSequence
|
||||||
{
|
{
|
||||||
$teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
|
$teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
|
||||||
$teamDifferencesComparisonLayerLocalFactors = $this->TeamDifferencesComparisonLayer->getLocalFactors();
|
$teamDifferencesComparisonLayerLocalFactors = $this->TeamDifferencesComparisonLayer->getLocalFactors();
|
||||||
@ -104,9 +104,9 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createMultipleTeamInnerPriorLoopSchedule()
|
private function createMultipleTeamInnerPriorLoopSchedule(): ScheduleLoop
|
||||||
{
|
{
|
||||||
$totalTeamDifferences = is_countable($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors()) ? count($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors()) : 0;
|
$totalTeamDifferences = count($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors());
|
||||||
|
|
||||||
$forwardScheduleList = [];
|
$forwardScheduleList = [];
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPriorSchedule(): ScheduleSequence
|
public function createPriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
$localFactors = $this->getLocalFactors();
|
$localFactors = $this->getLocalFactors();
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPosteriorSchedule(): ScheduleSequence
|
public function createPosteriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
$allFactors = [];
|
$allFactors = [];
|
||||||
$localFactors = $this->getLocalFactors();
|
$localFactors = $this->getLocalFactors();
|
||||||
|
@ -42,7 +42,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPriorSchedule(): ScheduleSequence
|
public function createPriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
$localFactors = $this->getLocalFactors();
|
$localFactors = $this->getLocalFactors();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
|||||||
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, $key . "'s performance");
|
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, $key . "'s performance");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPriorSchedule(): ScheduleSequence
|
public function createPriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
$localFactors = $this->getLocalFactors();
|
$localFactors = $this->getLocalFactors();
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPosteriorSchedule(): ScheduleSequence
|
public function createPosteriorSchedule(): ?ScheduleSequence
|
||||||
{
|
{
|
||||||
$localFactors = $this->getLocalFactors();
|
$localFactors = $this->getLocalFactors();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user