diff --git a/composer.lock b/composer.lock index 330a39f..b0a7254 100644 --- a/composer.lock +++ b/composer.lock @@ -394,16 +394,16 @@ }, { "name": "composer/xdebug-handler", - "version": "3.0.4", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255" + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255", - "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", "shasum": "" }, "require": { @@ -440,7 +440,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.4" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" }, "funding": [ { @@ -456,7 +456,7 @@ "type": "tidelift" } ], - "time": "2024-03-26T18:29:49+00:00" + "time": "2024-05-06T16:37:16+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -1330,16 +1330,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.28.0", + "version": "1.29.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", "shasum": "" }, "require": { @@ -1371,22 +1371,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0" }, - "time": "2024-04-03T18:51:33+00:00" + "time": "2024-05-06T12:04:23+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/666cb1703742cea9cc80fee631f0940e1592fa6e", + "reference": "666cb1703742cea9cc80fee631f0940e1592fa6e", "shasum": "" }, "require": { @@ -1431,7 +1431,7 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-05-13T06:02:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2020,16 +2020,16 @@ }, { "name": "rector/rector", - "version": "1.0.4", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "6e04d0eb087aef707fa0c5686d33d6ff61f4a555" + "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/6e04d0eb087aef707fa0c5686d33d6ff61f4a555", - "reference": "6e04d0eb087aef707fa0c5686d33d6ff61f4a555", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/73eb63e4f9011dba6b7c66c3262543014e352f34", + "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34", "shasum": "" }, "require": { @@ -2067,7 +2067,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/1.0.4" + "source": "https://github.com/rectorphp/rector/tree/1.0.5" }, "funding": [ { @@ -2075,7 +2075,7 @@ "type": "github" } ], - "time": "2024-04-05T09:01:07+00:00" + "time": "2024-05-10T05:31:15+00:00" }, { "name": "sebastian/cli-parser", @@ -2995,16 +2995,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.2.3", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab" + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/c95fd4db94ec199f798d4b5b4a81757bd20d88ab", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", "shasum": "" }, "require": { @@ -3017,6 +3017,11 @@ "spatie/pest-plugin-snapshots": "^1.1" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, "autoload": { "psr-4": { "Spatie\\ArrayToXml\\": "src" @@ -3042,7 +3047,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.2.3" + "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" }, "funding": [ { @@ -3054,7 +3059,7 @@ "type": "github" } ], - "time": "2024-02-07T10:39:02+00:00" + "time": "2024-05-01T10:20:27+00:00" }, { "name": "symfony/console", @@ -3149,6 +3154,73 @@ ], "time": "2024-04-18T09:29:19+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, { "name": "symfony/filesystem", "version": "v7.0.7", @@ -3594,21 +3666,22 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.2", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e" + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/11bbf19a0fb7b36345861e85c5768844c552906e", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^1.1|^2.0" + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -3616,7 +3689,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -3656,7 +3729,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" }, "funding": [ { @@ -3672,7 +3745,7 @@ "type": "tidelift" } ], - "time": "2023-12-19T21:51:00+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/string", @@ -3812,16 +3885,16 @@ }, { "name": "vimeo/psalm", - "version": "5.23.1", + "version": "5.24.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4" + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/8471a896ccea3526b26d082f4461eeea467f10a4", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/462c80e31c34e58cc4f750c656be3927e80e550e", + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e", "shasum": "" }, "require": { @@ -3918,7 +3991,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-03-11T20:33:46+00:00" + "time": "2024-05-01T19:32:08+00:00" }, { "name": "webmozart/assert", diff --git a/phpunit.xml b/phpunit.xml index bcdb3b9..eb94803 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + ./tests/ diff --git a/src/HashMap.php b/src/HashMap.php index 62ca46a..56e3f1b 100644 --- a/src/HashMap.php +++ b/src/HashMap.php @@ -19,7 +19,7 @@ class HashMap */ private array $hashToKey = []; - public function getValue(object $key): object + public function getValue(object $key): mixed { $hash = spl_object_id($key); diff --git a/src/PlayersRange.php b/src/PlayersRange.php index 81eb919..a921603 100644 --- a/src/PlayersRange.php +++ b/src/PlayersRange.php @@ -8,8 +8,4 @@ use DNW\Skills\Numerics\Range; class PlayersRange extends Range { - protected static function create(int $min, int $max): static - { - return new static($min, $max); - } } diff --git a/src/TeamsRange.php b/src/TeamsRange.php index 70b6518..79d5fb5 100644 --- a/src/TeamsRange.php +++ b/src/TeamsRange.php @@ -8,8 +8,4 @@ use DNW\Skills\Numerics\Range; class TeamsRange extends Range { - protected static function create(int $min, int $max): static - { - return new static($min, $max); - } } diff --git a/tests/FactorGraphs/VariableTest.php b/tests/FactorGraphs/VariableTest.php index 835f6d0..8fad3d6 100644 --- a/tests/FactorGraphs/VariableTest.php +++ b/tests/FactorGraphs/VariableTest.php @@ -7,7 +7,11 @@ namespace DNW\Skills\Tests\FactorGraphs; use DNW\Skills\FactorGraphs\Variable; use DNW\Skills\Numerics\GaussianDistribution; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; +#[CoversClass(Variable::class)] +#[UsesClass(GaussianDistribution::class)] class VariableTest extends TestCase { public function testGetterSetter(): void diff --git a/tests/GameInfoTest.php b/tests/GameInfoTest.php index 2311b88..f84ea24 100644 --- a/tests/GameInfoTest.php +++ b/tests/GameInfoTest.php @@ -5,8 +5,13 @@ declare(strict_types=1); namespace DNW\Skills\Tests; use DNW\Skills\GameInfo; +use \DNW\Skills\Rating; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; +#[CoversClass(GameInfo::class)] +#[UsesClass(Rating::class)] class GameInfoTest extends TestCase { public function testMembers(): void @@ -17,6 +22,6 @@ class GameInfoTest extends TestCase $this->assertEquals(3, $gi->getBeta()); $this->assertEquals(4, $gi->getDynamicsFactor()); $this->assertEquals(5, $gi->getDrawProbability()); - $this->assertInstanceOf(\DNW\Skills\Rating::class, $gi->getDefaultRating()); + $this->assertInstanceOf(Rating::class, $gi->getDefaultRating()); } } diff --git a/tests/GuardTest.php b/tests/GuardTest.php index b5a418b..42c97ec 100644 --- a/tests/GuardTest.php +++ b/tests/GuardTest.php @@ -7,7 +7,9 @@ namespace DNW\Skills\Tests; use DNW\Skills\Guard; use Exception; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +#[CoversClass(Guard::class)] class GuardTest extends TestCase { public function testargumentIsValidIndex(): void diff --git a/tests/HashMapTest.php b/tests/HashMapTest.php new file mode 100644 index 0000000..6bd1f62 --- /dev/null +++ b/tests/HashMapTest.php @@ -0,0 +1,35 @@ +assertEquals([], $h->getAllKeys()); + $this->assertEquals([], $h->getAllValues()); + + + $o1 = new \stdClass(); + $o2 = new \stdClass(); + + $h->setValue($o1, 1); + $h->setvalue($o2, 2); + + $this->assertEquals([1, 2], $h->getAllValues()); + + $this->assertEquals(1, $h->getvalue($o1)); + $this->assertEquals(2, $h->getvalue($o2)); + + $this->assertEquals(2, $h->count()); + } +} diff --git a/tests/Numerics/BasicMathTest.php b/tests/Numerics/BasicMathTest.php index f17c635..a79b6af 100644 --- a/tests/Numerics/BasicMathTest.php +++ b/tests/Numerics/BasicMathTest.php @@ -6,7 +6,9 @@ namespace DNW\Skills\Tests\Numerics; use DNW\Skills\Numerics\BasicMath; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +#[CoversClass(BasicMath::class)] class BasicMathTest extends TestCase { public function testSquare(): void diff --git a/tests/Numerics/GaussianDistributionTest.php b/tests/Numerics/GaussianDistributionTest.php index 27081f5..90ee863 100644 --- a/tests/Numerics/GaussianDistributionTest.php +++ b/tests/Numerics/GaussianDistributionTest.php @@ -7,7 +7,11 @@ namespace DNW\Skills\Tests\Numerics; use DNW\Skills\Numerics\BasicMath; use DNW\Skills\Numerics\GaussianDistribution; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; +#[CoversClass(GaussianDistribution::class)] +#[UsesClass(BasicMath::class)] class GaussianDistributionTest extends TestCase { private const ERROR_TOLERANCE = 0.000001; diff --git a/tests/Numerics/RangeTest.php b/tests/Numerics/RangeTest.php index 2f4cd32..5eec974 100644 --- a/tests/Numerics/RangeTest.php +++ b/tests/Numerics/RangeTest.php @@ -6,8 +6,10 @@ namespace DNW\Skills\Tests\Numerics; use DNW\Skills\Numerics\Range; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use Exception; +#[CoversClass(Range::class)] class RangeTest extends TestCase { public function testConstructInvalidParam(): void diff --git a/tests/PlayerTest.php b/tests/PlayerTest.php index 0602a4e..b6f6461 100644 --- a/tests/PlayerTest.php +++ b/tests/PlayerTest.php @@ -5,8 +5,14 @@ declare(strict_types=1); namespace DNW\Skills\Tests; use DNW\Skills\Player; +use DNW\Skills\Guard; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; + +#[CoversClass(Player::class)] +#[UsesClass(Guard::class)] class PlayerTest extends TestCase { public function testPlayerObjectGetterSetter(): void diff --git a/tests/RankSorterTest.php b/tests/RankSorterTest.php index 7b98e4f..87db13a 100644 --- a/tests/RankSorterTest.php +++ b/tests/RankSorterTest.php @@ -6,7 +6,9 @@ namespace DNW\Skills\Tests; use DNW\Skills\RankSorter; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +#[CoversClass(RankSorter::class)] class RankSorterTest extends TestCase { public function testSort(): void diff --git a/tests/RatingTest.php b/tests/RatingTest.php index 80cb8b5..1689edc 100644 --- a/tests/RatingTest.php +++ b/tests/RatingTest.php @@ -5,8 +5,15 @@ declare(strict_types=1); namespace DNW\Skills\Tests; use DNW\Skills\Rating; +use DNW\Skills\Numerics\BasicMath; +use DNW\Skills\Numerics\GaussianDistribution; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; +#[CoversClass(Rating::class)] +#[UsesClass(BasicMath::class)] +#[UsesClass(GaussianDistribution::class)] class RatingTest extends TestCase { public function testGetRatingParameters(): void diff --git a/tests/TrueSkill/DrawMarginTest.php b/tests/TrueSkill/DrawMarginTest.php index 4584f9e..eb807d3 100644 --- a/tests/TrueSkill/DrawMarginTest.php +++ b/tests/TrueSkill/DrawMarginTest.php @@ -5,8 +5,15 @@ declare(strict_types=1); namespace DNW\Skills\Tests\TrueSkill; use DNW\Skills\TrueSkill\DrawMargin; +use DNW\Skills\Numerics\BasicMath; +use DNW\Skills\Numerics\GaussianDistribution; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; +#[CoversClass(DrawMargin::class)] +#[UsesClass(BasicMath::class)] +#[UsesClass(GaussianDistribution::class)] class DrawMarginTest extends TestCase { private const ERROR_TOLERANCE = 0.000001; @@ -23,6 +30,6 @@ class DrawMarginTest extends TestCase private function assertDrawMargin(float $drawProbability, float $beta, float $expected): void { $actual = DrawMargin::getDrawMarginFromDrawProbability($drawProbability, $beta); - $this->assertEqualsWithDelta($expected, $actual, DrawMarginTest::ERROR_TOLERANCE); + $this->assertEqualsWithDelta($expected, $actual, self::ERROR_TOLERANCE); } }