Rector standards slowly being applied. PHP Version first.

This commit is contained in:
2024-02-20 14:21:44 +00:00
parent c72112c5aa
commit 660fbd1486
25 changed files with 108 additions and 36 deletions

View File

@ -15,9 +15,9 @@ abstract class Factor implements \Stringable
*/
private array $messages = [];
private HashMap $messageToVariableBinding;
private readonly HashMap $messageToVariableBinding;
private string $name;
private readonly string $name;
/**
* @var Variable[] $variables

View File

@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
class KeyedVariable extends Variable
{
public function __construct(private mixed $key, string $name, mixed $prior)
public function __construct(private readonly mixed $key, string $name, mixed $prior)
{
parent::__construct($name, $prior);
}

View File

@ -8,7 +8,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
class Message implements \Stringable
{
public function __construct(private GaussianDistribution $value, private string $name)
public function __construct(private GaussianDistribution $value, private readonly string $name)
{
}

View File

@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
abstract class Schedule implements \Stringable
{
protected function __construct(private string $name)
protected function __construct(private readonly string $name)
{
}

View File

@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
class ScheduleLoop extends Schedule
{
public function __construct(string $name, private readonly Schedule $scheduleToLoop, private float $maxDelta)
public function __construct(string $name, private readonly Schedule $scheduleToLoop, private readonly float $maxDelta)
{
parent::__construct($name);
}

View File

@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
class ScheduleStep extends Schedule
{
public function __construct(string $name, private readonly Factor $factor, private int $index)
public function __construct(string $name, private readonly Factor $factor, private readonly int $index)
{
parent::__construct($name);
}

View File

@ -8,7 +8,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
class Variable implements \Stringable
{
private string $name;
private readonly string $name;
private mixed $value;

View File

@ -20,11 +20,11 @@ class GameInfo
private const DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333;
public function __construct(
private float $initialMean = self::DEFAULT_INITIAL_MEAN,
private float $initialStandardDeviation = self::DEFAULT_INITIAL_STANDARD_DEVIATION,
private float $beta = self::DEFAULT_BETA,
private float $dynamicsFactor = self::DEFAULT_DYNAMICS_FACTOR,
private float $drawProbability = self::DEFAULT_DRAW_PROBABILITY
private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN,
private readonly float $initialStandardDeviation = self::DEFAULT_INITIAL_STANDARD_DEVIATION,
private readonly float $beta = self::DEFAULT_BETA,
private readonly float $dynamicsFactor = self::DEFAULT_DYNAMICS_FACTOR,
private readonly float $drawProbability = self::DEFAULT_DRAW_PROBABILITY
)
{
}

View File

@ -13,7 +13,7 @@ class Matrix
/**
* @param array<int,array<int,float>> $matrixRowData
*/
public function __construct(private int $rowCount = 0, private int $columnCount = 0, private array $matrixRowData = [])
public function __construct(private readonly int $rowCount = 0, private readonly int $columnCount = 0, private array $matrixRowData = [])
{
}

View File

@ -11,7 +11,7 @@ use Exception;
class Range
{
final public function __construct(private int $min, private int $max)
final public function __construct(private readonly int $min, private readonly int $max)
{
if ($min > $max) {
throw new Exception('min > max');

View File

@ -13,9 +13,9 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
private const DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0;
private float $PartialPlayPercentage;
private readonly float $PartialPlayPercentage;
private float $PartialUpdatePercentage;
private readonly float $PartialUpdatePercentage;
/**
* Constructs a player.
@ -25,7 +25,7 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
* @param float $partialUpdatePercentage Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
*/
public function __construct(
private mixed $Id,
private readonly mixed $Id,
float $partialPlayPercentage = self::DEFAULT_PARTIAL_PLAY_PERCENTAGE,
float $partialUpdatePercentage = self::DEFAULT_PARTIAL_UPDATE_PERCENTAGE
)

View File

@ -18,7 +18,7 @@ class Rating implements \Stringable
* @param float $standardDeviation The standard deviation of the rating (also known as s).
* @param float|int $conservativeStandardDeviationMultiplier optional The number of standardDeviations to subtract from the mean to achieve a conservative rating.
*/
public function __construct(private float $mean, private float $standardDeviation, private float|int $conservativeStandardDeviationMultiplier = self::CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER)
public function __construct(private readonly float $mean, private readonly float $standardDeviation, private readonly float|int $conservativeStandardDeviationMultiplier = self::CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER)
{
}

View File

@ -6,7 +6,7 @@ namespace DNW\Skills;
class RatingContainer
{
private HashMap $playerToRating;
private readonly HashMap $playerToRating;
public function __construct()
{

View File

@ -12,7 +12,7 @@ use Exception;
abstract class SkillCalculator
{
protected function __construct(
private int $supportedOptions,
private readonly int $supportedOptions,
private readonly TeamsRange $totalTeamsAllowed,
private readonly PlayersRange $playersPerTeamAllowed
)

View File

@ -16,7 +16,7 @@ use DNW\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
*/
class GaussianGreaterThanFactor extends GaussianFactor
{
private float $epsilon;
private readonly float $epsilon;
public function __construct(float $epsilon, Variable $variable)
{

View File

@ -17,7 +17,7 @@ use Exception;
*/
class GaussianLikelihoodFactor extends GaussianFactor
{
private float $precision;
private readonly float $precision;
public function __construct(float $betaSquared, Variable $variable1, Variable $variable2)
{

View File

@ -15,7 +15,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
*/
class GaussianPriorFactor extends GaussianFactor
{
private GaussianDistribution $newMessage;
private readonly GaussianDistribution $newMessage;
public function __construct(float $mean, float $variance, Variable $variable)
{

View File

@ -16,7 +16,7 @@ use DNW\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
*/
class GaussianWithinFactor extends GaussianFactor
{
private float $epsilon;
private readonly float $epsilon;
public function __construct(float $epsilon, Variable $variable)
{

View File

@ -11,7 +11,7 @@ use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
{
private float $epsilon;
private readonly float $epsilon;
/**
* @param int[] $teamRanks

View File

@ -28,7 +28,7 @@ class TrueSkillFactorGraph extends FactorGraph
*/
private array $layers;
private PlayerPriorValuesToSkillsLayer $priorLayer;
private readonly PlayerPriorValuesToSkillsLayer $priorLayer;
/**
* @param GameInfo $gameInfo Parameters for the game.