diff --git a/composer.json b/composer.json index 715f398..93c20e8 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "dnw/php-trueskill", - "description": "Trueskill implementation by Moserware updated for PHP 8.2", + "description": "Trueskill implementation by Moserware updated for PHP 8.4", "keywords": ["trueskill", "matchmaking", "ranking", "skill", "elo"], "require": { - "php": "^8.2" + "php": "^8.4" }, "require-dev": { "phpstan/phpstan": "^1.0", @@ -51,7 +51,6 @@ "@test", "@lint", "@analyze", - "@document", "@metrics", "@html" ] diff --git a/composer.lock b/composer.lock index 19dc719..8ff776d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9bcad23ed6b67a87b77c11db92614e65", + "content-hash": "b812db257eb7996abdfd76cc1a74431f", "packages": [], "packages-dev": [ { "name": "amphp/amp", - "version": "v3.0.2", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0" + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/138801fb68cfc9c329da8a7b39d01ce7291ee4b0", - "reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0", + "url": "https://api.github.com/repos/amphp/amp/zipball/7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", "shasum": "" }, "require": { @@ -78,7 +78,7 @@ ], "support": { "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v3.0.2" + "source": "https://github.com/amphp/amp/tree/v3.1.0" }, "funding": [ { @@ -86,7 +86,7 @@ "type": "github" } ], - "time": "2024-05-10T21:37:46+00:00" + "time": "2025-01-26T16:07:39+00:00" }, { "name": "amphp/byte-stream", @@ -227,16 +227,16 @@ }, { "name": "amphp/pipeline", - "version": "v1.2.1", + "version": "v1.2.2", "source": { "type": "git", "url": "https://github.com/amphp/pipeline.git", - "reference": "66c095673aa5b6e689e63b52d19e577459129ab3" + "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/pipeline/zipball/66c095673aa5b6e689e63b52d19e577459129ab3", - "reference": "66c095673aa5b6e689e63b52d19e577459129ab3", + "url": "https://api.github.com/repos/amphp/pipeline/zipball/97cbf289f4d8877acfe58dd90ed5a4370a43caa4", + "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4", "shasum": "" }, "require": { @@ -282,7 +282,7 @@ ], "support": { "issues": "https://github.com/amphp/pipeline/issues", - "source": "https://github.com/amphp/pipeline/tree/v1.2.1" + "source": "https://github.com/amphp/pipeline/tree/v1.2.2" }, "funding": [ { @@ -290,7 +290,7 @@ "type": "github" } ], - "time": "2024-07-04T00:56:47+00:00" + "time": "2025-01-19T15:42:46+00:00" }, { "name": "amphp/serialization", @@ -1641,16 +1641,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.15", + "version": "1.12.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1" + "reference": "e0bb5cb78545aae631220735aa706eac633a6be9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c91d4e8bc056f46cf653656e6f71004b254574d1", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e0bb5cb78545aae631220735aa706eac633a6be9", + "reference": "e0bb5cb78545aae631220735aa706eac633a6be9", "shasum": "" }, "require": { @@ -1695,7 +1695,7 @@ "type": "github" } ], - "time": "2025-01-05T16:40:22+00:00" + "time": "2025-01-21T14:50:05+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2022,16 +2022,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.2", + "version": "11.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3" + "reference": "30e319e578a7b5da3543073e30002bf82042f701" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/153d0531b9f7e883c5053160cad6dd5ac28140b3", - "reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/30e319e578a7b5da3543073e30002bf82042f701", + "reference": "30e319e578a7b5da3543073e30002bf82042f701", "shasum": "" }, "require": { @@ -2052,7 +2052,7 @@ "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.2", - "sebastian/comparator": "^6.2.1", + "sebastian/comparator": "^6.3.0", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.0", "sebastian/exporter": "^6.3.0", @@ -2103,7 +2103,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.3" }, "funding": [ { @@ -2119,7 +2119,7 @@ "type": "tidelift" } ], - "time": "2024-12-21T05:51:08+00:00" + "time": "2025-01-13T09:36:00+00:00" }, { "name": "psalm/plugin-phpunit", @@ -4231,12 +4231,12 @@ "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "765dcbfe43002e52e4808b65561842784fe7bcc7" + "reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/765dcbfe43002e52e4808b65561842784fe7bcc7", - "reference": "765dcbfe43002e52e4808b65561842784fe7bcc7", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8", + "reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8", "shasum": "" }, "require": { @@ -4254,15 +4254,15 @@ "ext-simplexml": "*", "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.1", - "felixfbecker/language-server-protocol": "^1.5.2", + "felixfbecker/language-server-protocol": "^1.5.3", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "nikic/php-parser": "^5.0.0", "php": "~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0", "sebastian/diff": "^4.0 || ^5.0 || ^6.0", "spatie/array-to-xml": "^2.17.0 || ^3.0", - "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" + "symfony/console": "^6.0 || ^7.0", + "symfony/filesystem": "^6.0 || ^7.0" }, "provide": { "psalm/psalm": "self.version" @@ -4279,10 +4279,10 @@ "phpstan/phpdoc-parser": "^1.6", "phpunit/phpunit": "^9.6", "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18", + "psalm/plugin-phpunit": "^0.19", "slevomat/coding-standard": "^8.4", "squizlabs/php_codesniffer": "^3.6", - "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" + "symfony/process": "^6.0 || ^7.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -4303,7 +4303,8 @@ "dev-3.x": "3.x-dev", "dev-4.x": "4.x-dev", "dev-5.x": "5.x-dev", - "dev-master": "6.x-dev" + "dev-6.x": "6.x-dev", + "dev-master": "7.x-dev" } }, "autoload": { @@ -4332,7 +4333,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-12-15T08:19:36+00:00" + "time": "2025-01-27T10:58:44+00:00" }, { "name": "webmozart/assert", @@ -4402,7 +4403,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^8.2" + "php": "^8.4" }, "platform-dev": {}, "plugin-api-version": "2.6.0" diff --git a/src/GameInfo.php b/src/GameInfo.php index 3b56b4c..4afcc94 100644 --- a/src/GameInfo.php +++ b/src/GameInfo.php @@ -12,18 +12,18 @@ class GameInfo /** * Default initial mean / 6 */ - private const DEFAULT_BETA = 4.1666666666666666666666666666667; + private const float DEFAULT_BETA = 4.1666666666666666666666666666667; - private const DEFAULT_DRAW_PROBABILITY = 0.10; + private const float DEFAULT_DRAW_PROBABILITY = 0.10; /** * Default initial mean / 300 */ - private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333; + private const float DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333; - private const DEFAULT_INITIAL_MEAN = 25.0; + private const float DEFAULT_INITIAL_MEAN = 25.0; - private const DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333; + private const float DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333; public function __construct( private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN, diff --git a/src/Numerics/GaussianDistribution.php b/src/Numerics/GaussianDistribution.php index 940d5c1..cff1d5f 100644 --- a/src/Numerics/GaussianDistribution.php +++ b/src/Numerics/GaussianDistribution.php @@ -12,9 +12,9 @@ namespace DNW\Skills\Numerics; */ class GaussianDistribution { - private const DEFAULT_STANDARD_DEVIATION = 1.0; + private const float DEFAULT_STANDARD_DEVIATION = 1.0; - private const DEFAULT_MEAN = 0.0; + private const float DEFAULT_MEAN = 0.0; /** * Square Root 2π. @@ -23,7 +23,7 @@ class GaussianDistribution * * @link https://www.wolframalpha.com/input?i=sqrt%282*pi%29 Source of value */ - private const M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763; + private const float M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763; /** * Log of Square Root 2π. @@ -32,7 +32,7 @@ class GaussianDistribution * * @link https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29 Source of value */ - private const M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404; + private const float M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404; // precision and precisionMean are used because they make multiplying and dividing simpler // (see the accompanying math paper for more details) diff --git a/src/Player.php b/src/Player.php index 780c47e..d0aa075 100644 --- a/src/Player.php +++ b/src/Player.php @@ -9,9 +9,9 @@ namespace DNW\Skills; */ class Player implements ISupportPartialPlay, ISupportPartialUpdate { - private const DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time + private const float DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time - private const DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0; + private const float DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0; private readonly float $PartialPlayPct; diff --git a/src/Rating.php b/src/Rating.php index b411b4f..e1fe7bc 100644 --- a/src/Rating.php +++ b/src/Rating.php @@ -11,7 +11,7 @@ use DNW\Skills\Numerics\GaussianDistribution; */ class Rating { - private const CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3; + private const float CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3; /** * Constructs a rating. diff --git a/src/Team.php b/src/Team.php index 9d7a602..b49f0fe 100644 --- a/src/Team.php +++ b/src/Team.php @@ -6,7 +6,7 @@ namespace DNW\Skills; class Team extends RatingContainer { - public function __construct(Player $player = NULL, Rating $rating = NULL) + public function __construct(?Player $player = NULL, ?Rating $rating = NULL) { parent::__construct(); if (! $player instanceof Player) { diff --git a/tests/Numerics/GaussianDistributionTest.php b/tests/Numerics/GaussianDistributionTest.php index 5f08980..d2660e9 100644 --- a/tests/Numerics/GaussianDistributionTest.php +++ b/tests/Numerics/GaussianDistributionTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\Attributes\UsesClass; #[UsesClass(BasicMath::class)] class GaussianDistributionTest extends TestCase { - private const ERROR_TOLERANCE = 0.000001; + private const float ERROR_TOLERANCE = 0.000001; public function testGetters(): void { diff --git a/tests/TrueSkill/DrawMarginTest.php b/tests/TrueSkill/DrawMarginTest.php index eb807d3..228f7c7 100644 --- a/tests/TrueSkill/DrawMarginTest.php +++ b/tests/TrueSkill/DrawMarginTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\UsesClass; #[UsesClass(GaussianDistribution::class)] class DrawMarginTest extends TestCase { - private const ERROR_TOLERANCE = 0.000001; + private const float ERROR_TOLERANCE = 0.000001; public function testGetDrawMarginFromDrawProbability(): void { diff --git a/tests/TrueSkill/TrueSkillCalculatorTests.php b/tests/TrueSkill/TrueSkillCalculatorTests.php index 430575d..a8c00a3 100644 --- a/tests/TrueSkill/TrueSkillCalculatorTests.php +++ b/tests/TrueSkill/TrueSkillCalculatorTests.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; class TrueSkillCalculatorTests { - private const ERROR_TOLERANCE_TRUESKILL = 0.085; + private const float ERROR_TOLERANCE_TRUESKILL = 0.085; - private const ERROR_TOLERANCE_MATCH_QUALITY = 0.0005; + private const float ERROR_TOLERANCE_MATCH_QUALITY = 0.0005; // These are the roll-up ones