mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Rector standards slowly being applied. PHP Version first.
This commit is contained in:
@ -10,7 +10,8 @@
|
|||||||
"vimeo/psalm": "^5.21.1",
|
"vimeo/psalm": "^5.21.1",
|
||||||
"phpmetrics/phpmetrics": "^3.0-dev",
|
"phpmetrics/phpmetrics": "^3.0-dev",
|
||||||
"phpunit/phpunit": "^10.5",
|
"phpunit/phpunit": "^10.5",
|
||||||
"psalm/plugin-phpunit": "^0.18.4"
|
"psalm/plugin-phpunit": "^0.18.4",
|
||||||
|
"rector/rector": "^1.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
58
composer.lock
generated
58
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "ae420a83c061b5eb7f6ec5487f01643a",
|
"content-hash": "ba51339b2bd54ead227bc16656795670",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
@ -1925,6 +1925,62 @@
|
|||||||
},
|
},
|
||||||
"time": "2021-07-14T16:46:02+00:00"
|
"time": "2021-07-14T16:46:02+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "rector/rector",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/rectorphp/rector.git",
|
||||||
|
"reference": "258b775511e62a7188f8ce114d44acaf244d9a7d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/rectorphp/rector/zipball/258b775511e62a7188f8ce114d44acaf244d9a7d",
|
||||||
|
"reference": "258b775511e62a7188f8ce114d44acaf244d9a7d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0",
|
||||||
|
"phpstan/phpstan": "^1.10.57"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"rector/rector-doctrine": "*",
|
||||||
|
"rector/rector-downgrade-php": "*",
|
||||||
|
"rector/rector-phpunit": "*",
|
||||||
|
"rector/rector-symfony": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/rector"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
||||||
|
"keywords": [
|
||||||
|
"automation",
|
||||||
|
"dev",
|
||||||
|
"migration",
|
||||||
|
"refactoring"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/rectorphp/rector/issues",
|
||||||
|
"source": "https://github.com/rectorphp/rector/tree/1.0.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/tomasvotruba",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-02-16T07:53:23+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/cli-parser",
|
"name": "sebastian/cli-parser",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
19
rector.php
Normal file
19
rector.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Rector\Config\RectorConfig;
|
||||||
|
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
||||||
|
|
||||||
|
return RectorConfig::configure()
|
||||||
|
->withPaths([
|
||||||
|
__DIR__ . '/benchmark',
|
||||||
|
__DIR__ . '/examples',
|
||||||
|
__DIR__ . '/src',
|
||||||
|
__DIR__ . '/tests',
|
||||||
|
])
|
||||||
|
// uncomment to reach your current PHP version
|
||||||
|
->withPhpSets()
|
||||||
|
->withRules([
|
||||||
|
AddVoidReturnTypeWhereNoReturnRector::class,
|
||||||
|
]);
|
@ -15,9 +15,9 @@ abstract class Factor implements \Stringable
|
|||||||
*/
|
*/
|
||||||
private array $messages = [];
|
private array $messages = [];
|
||||||
|
|
||||||
private HashMap $messageToVariableBinding;
|
private readonly HashMap $messageToVariableBinding;
|
||||||
|
|
||||||
private string $name;
|
private readonly string $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Variable[] $variables
|
* @var Variable[] $variables
|
||||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
|
|||||||
|
|
||||||
class KeyedVariable extends Variable
|
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);
|
parent::__construct($name, $prior);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
|||||||
|
|
||||||
class Message implements \Stringable
|
class Message implements \Stringable
|
||||||
{
|
{
|
||||||
public function __construct(private GaussianDistribution $value, private string $name)
|
public function __construct(private GaussianDistribution $value, private readonly string $name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
|
|||||||
|
|
||||||
abstract class Schedule implements \Stringable
|
abstract class Schedule implements \Stringable
|
||||||
{
|
{
|
||||||
protected function __construct(private string $name)
|
protected function __construct(private readonly string $name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
|
|||||||
|
|
||||||
class ScheduleLoop extends Schedule
|
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);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills\FactorGraphs;
|
|||||||
|
|
||||||
class ScheduleStep extends Schedule
|
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);
|
parent::__construct($name);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
|||||||
|
|
||||||
class Variable implements \Stringable
|
class Variable implements \Stringable
|
||||||
{
|
{
|
||||||
private string $name;
|
private readonly string $name;
|
||||||
|
|
||||||
private mixed $value;
|
private mixed $value;
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@ class GameInfo
|
|||||||
private const DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333;
|
private const DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private float $initialMean = self::DEFAULT_INITIAL_MEAN,
|
private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN,
|
||||||
private float $initialStandardDeviation = self::DEFAULT_INITIAL_STANDARD_DEVIATION,
|
private readonly float $initialStandardDeviation = self::DEFAULT_INITIAL_STANDARD_DEVIATION,
|
||||||
private float $beta = self::DEFAULT_BETA,
|
private readonly float $beta = self::DEFAULT_BETA,
|
||||||
private float $dynamicsFactor = self::DEFAULT_DYNAMICS_FACTOR,
|
private readonly float $dynamicsFactor = self::DEFAULT_DYNAMICS_FACTOR,
|
||||||
private float $drawProbability = self::DEFAULT_DRAW_PROBABILITY
|
private readonly float $drawProbability = self::DEFAULT_DRAW_PROBABILITY
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class Matrix
|
|||||||
/**
|
/**
|
||||||
* @param array<int,array<int,float>> $matrixRowData
|
* @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 = [])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use Exception;
|
|||||||
|
|
||||||
class Range
|
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) {
|
if ($min > $max) {
|
||||||
throw new Exception('min > max');
|
throw new Exception('min > max');
|
||||||
|
@ -13,9 +13,9 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
|
|||||||
|
|
||||||
private const DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0;
|
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.
|
* 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.
|
* @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(
|
public function __construct(
|
||||||
private mixed $Id,
|
private readonly mixed $Id,
|
||||||
float $partialPlayPercentage = self::DEFAULT_PARTIAL_PLAY_PERCENTAGE,
|
float $partialPlayPercentage = self::DEFAULT_PARTIAL_PLAY_PERCENTAGE,
|
||||||
float $partialUpdatePercentage = self::DEFAULT_PARTIAL_UPDATE_PERCENTAGE
|
float $partialUpdatePercentage = self::DEFAULT_PARTIAL_UPDATE_PERCENTAGE
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ class Rating implements \Stringable
|
|||||||
* @param float $standardDeviation The standard deviation of the rating (also known as s).
|
* @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.
|
* @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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills;
|
|||||||
|
|
||||||
class RatingContainer
|
class RatingContainer
|
||||||
{
|
{
|
||||||
private HashMap $playerToRating;
|
private readonly HashMap $playerToRating;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ use Exception;
|
|||||||
abstract class SkillCalculator
|
abstract class SkillCalculator
|
||||||
{
|
{
|
||||||
protected function __construct(
|
protected function __construct(
|
||||||
private int $supportedOptions,
|
private readonly int $supportedOptions,
|
||||||
private readonly TeamsRange $totalTeamsAllowed,
|
private readonly TeamsRange $totalTeamsAllowed,
|
||||||
private readonly PlayersRange $playersPerTeamAllowed
|
private readonly PlayersRange $playersPerTeamAllowed
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ use DNW\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
|||||||
*/
|
*/
|
||||||
class GaussianGreaterThanFactor extends GaussianFactor
|
class GaussianGreaterThanFactor extends GaussianFactor
|
||||||
{
|
{
|
||||||
private float $epsilon;
|
private readonly float $epsilon;
|
||||||
|
|
||||||
public function __construct(float $epsilon, Variable $variable)
|
public function __construct(float $epsilon, Variable $variable)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ use Exception;
|
|||||||
*/
|
*/
|
||||||
class GaussianLikelihoodFactor extends GaussianFactor
|
class GaussianLikelihoodFactor extends GaussianFactor
|
||||||
{
|
{
|
||||||
private float $precision;
|
private readonly float $precision;
|
||||||
|
|
||||||
public function __construct(float $betaSquared, Variable $variable1, Variable $variable2)
|
public function __construct(float $betaSquared, Variable $variable1, Variable $variable2)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
|||||||
*/
|
*/
|
||||||
class GaussianPriorFactor extends GaussianFactor
|
class GaussianPriorFactor extends GaussianFactor
|
||||||
{
|
{
|
||||||
private GaussianDistribution $newMessage;
|
private readonly GaussianDistribution $newMessage;
|
||||||
|
|
||||||
public function __construct(float $mean, float $variance, Variable $variable)
|
public function __construct(float $mean, float $variance, Variable $variable)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ use DNW\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
|||||||
*/
|
*/
|
||||||
class GaussianWithinFactor extends GaussianFactor
|
class GaussianWithinFactor extends GaussianFactor
|
||||||
{
|
{
|
||||||
private float $epsilon;
|
private readonly float $epsilon;
|
||||||
|
|
||||||
public function __construct(float $epsilon, Variable $variable)
|
public function __construct(float $epsilon, Variable $variable)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
|
|||||||
|
|
||||||
class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
|
class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
|
||||||
{
|
{
|
||||||
private float $epsilon;
|
private readonly float $epsilon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int[] $teamRanks
|
* @param int[] $teamRanks
|
||||||
|
@ -28,7 +28,7 @@ class TrueSkillFactorGraph extends FactorGraph
|
|||||||
*/
|
*/
|
||||||
private array $layers;
|
private array $layers;
|
||||||
|
|
||||||
private PlayerPriorValuesToSkillsLayer $priorLayer;
|
private readonly PlayerPriorValuesToSkillsLayer $priorLayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GameInfo $gameInfo Parameters for the game.
|
* @param GameInfo $gameInfo Parameters for the game.
|
||||||
|
@ -20,12 +20,8 @@ class BasicMathTest extends TestCase
|
|||||||
{
|
{
|
||||||
$arr = [1, 1, 1, 1];
|
$arr = [1, 1, 1, 1];
|
||||||
|
|
||||||
$func_return = function (float $f): float {
|
$func_return = fn(float $f): float => $f;
|
||||||
return $f;
|
$func_double = fn(float $f): float => $f * 2;
|
||||||
};
|
|
||||||
$func_double = function (float $f): float {
|
|
||||||
return $f * 2;
|
|
||||||
};
|
|
||||||
$this->assertEquals(4, BasicMath::sum($arr, $func_return));
|
$this->assertEquals(4, BasicMath::sum($arr, $func_return));
|
||||||
$this->assertEquals(8, BasicMath::sum($arr, $func_double));
|
$this->assertEquals(8, BasicMath::sum($arr, $func_double));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ class MatrixTest extends TestCase
|
|||||||
|
|
||||||
$b = new SquareMatrix(4, 3,
|
$b = new SquareMatrix(4, 3,
|
||||||
2, 1);
|
2, 1);
|
||||||
|
|
||||||
$sum = Matrix::add($a, $b);
|
$sum = Matrix::add($a, $b);
|
||||||
|
|
||||||
$result = new SquareMatrix(5, 5, 5, 5);
|
$result = new SquareMatrix(5, 5, 5, 5);
|
||||||
|
Reference in New Issue
Block a user