mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-03 17:52:29 +01:00 
			
		
		
		
	More coding standards.
Diagrams in API documentation
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<phive xmlns="https://phar.io/phive">
 | 
			
		||||
  <phar name="phpmd" version="^2.15.0" installed="2.15.0" location="./tools/phpmd" copy="false"/>
 | 
			
		||||
  <phar name="overtrue/phplint" version="^9.6.2" installed="9.6.2" location="./tools/phplint" copy="false"/>
 | 
			
		||||
  <phar name="phpstan" version="^2.1.12" installed="2.1.14" location="./tools/phpstan" copy="false"/>
 | 
			
		||||
  <phar name="psalm" version="^7.0.0-beta6" installed="7.0.0-beta7" location="./tools/psalm" copy="false"/>
 | 
			
		||||
  <phar name="phpcs" version="^3.12.2" installed="3.13.0" location="./tools/phpcs" copy="false"/>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								.phpcs.xml
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								.phpcs.xml
									
									
									
									
									
								
							@@ -6,6 +6,11 @@
 | 
			
		||||
    <file>tests/</file>
 | 
			
		||||
    <file>benchmark/</file>
 | 
			
		||||
 | 
			
		||||
    <arg name="basepath" value="."/>
 | 
			
		||||
    <arg name="colors"/>
 | 
			
		||||
    <arg name="parallel" value="8"/>
 | 
			
		||||
    <arg name="report" value="emacs"/>
 | 
			
		||||
    <arg value="p"/>
 | 
			
		||||
 | 
			
		||||
    <rule ref="PSR1">
 | 
			
		||||
        <exclude name="Generic.Files.LineLength"/>
 | 
			
		||||
@@ -18,23 +23,19 @@
 | 
			
		||||
        <exclude name="Generic.Files.LowercasedFilename.NotFound"/>
 | 
			
		||||
        <exclude name="Generic.PHP.ClosingPHPTag.NotFound"/>
 | 
			
		||||
        <exclude name="Generic.Files.EndFileNoNewline.Found"/>
 | 
			
		||||
        <exclude name="Generic.Files.EndFileNoNewline.Found"/>
 | 
			
		||||
        <exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
 | 
			
		||||
        <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine"/>
 | 
			
		||||
        <exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine"/>
 | 
			
		||||
        <exclude name="Generic.PHP.LowerCaseConstant.Found"/>
 | 
			
		||||
        <exclude name="Generic.Formatting.SpaceAfterCast"/>
 | 
			
		||||
        <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
 | 
			
		||||
        <exclude name="Generic.Commenting.DocComment.MissingShort"/>
 | 
			
		||||
        <exclude name="Generic.NamingConventions.AbstractClassNamePrefix.Missing"/>
 | 
			
		||||
        <exclude name="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"/>
 | 
			
		||||
        <exclude name="Generic.NamingConventions.InterfaceNameSuffix.Missing"/>
 | 
			
		||||
        <exclude name="Generic.Commenting.Todo.TaskFound"/>
 | 
			
		||||
        <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUse"/>
 | 
			
		||||
        <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed"/>
 | 
			
		||||
        <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed"/>
 | 
			
		||||
        <exclude name="Generic.Formatting.SpaceBeforeCast.NoSpace"/>
 | 
			
		||||
        <exclude name="Generic.CodeAnalysis.UselessOverridingMethod.Found"/>
 | 
			
		||||
        
 | 
			
		||||
        <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace"/>
 | 
			
		||||
    </rule>
 | 
			
		||||
 | 
			
		||||
@@ -50,4 +51,25 @@
 | 
			
		||||
            </property>
 | 
			
		||||
        </properties>
 | 
			
		||||
    </rule>
 | 
			
		||||
 | 
			
		||||
    <rule ref="Generic.Formatting.SpaceAfterCast">
 | 
			
		||||
        <properties>
 | 
			
		||||
            <property name="spacing" value="0"/>
 | 
			
		||||
        </properties>
 | 
			
		||||
    </rule>
 | 
			
		||||
 | 
			
		||||
    <!-- Do not allow unreachable code. -->
 | 
			
		||||
    <rule ref="Squiz.PHP.NonExecutableCode"/>
 | 
			
		||||
 | 
			
		||||
    <!-- Do not allow ambiguous conditions. -->
 | 
			
		||||
    <rule ref="Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence"/>
 | 
			
		||||
 | 
			
		||||
    <!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
 | 
			
		||||
    <rule ref="Generic.Strings.UnnecessaryStringConcat" />
 | 
			
		||||
 | 
			
		||||
    <!-- This test file specifically *needs* Windows line endings for testing purposes. -->
 | 
			
		||||
    <rule ref="Generic.Files.LineEndings.InvalidEOLChar" />
 | 
			
		||||
 | 
			
		||||
    <!-- Avoid false positive with this sniff detecting itself -->
 | 
			
		||||
    <rule ref="Generic.Commenting.Todo"/>
 | 
			
		||||
</ruleset>
 | 
			
		||||
							
								
								
									
										12
									
								
								.phplint.yml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								.phplint.yml
									
									
									
									
									
								
							@@ -1,12 +0,0 @@
 | 
			
		||||
path:
 | 
			
		||||
  - src/
 | 
			
		||||
  - tests/
 | 
			
		||||
  - benchmark/
 | 
			
		||||
jobs: 10
 | 
			
		||||
extensions:
 | 
			
		||||
  - php
 | 
			
		||||
exclude:
 | 
			
		||||
  - vendor
 | 
			
		||||
warning: true
 | 
			
		||||
memory-limit: -1
 | 
			
		||||
log-junit: "output/lint.xml"
 | 
			
		||||
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
{
 | 
			
		||||
    "php.version": "8.4"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4317
									
								
								CodeStandard.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4317
									
								
								CodeStandard.md
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,7 +1,13 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "dnw/php-trueskill",
 | 
			
		||||
  "description": "Trueskill implementation by Moserware updated for PHP 8.4",
 | 
			
		||||
  "keywords": ["trueskill", "matchmaking", "ranking", "skill", "elo"],
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "trueskill",
 | 
			
		||||
    "matchmaking",
 | 
			
		||||
    "ranking",
 | 
			
		||||
    "skill",
 | 
			
		||||
    "elo"
 | 
			
		||||
  ],
 | 
			
		||||
  "require": {
 | 
			
		||||
    "php": "^8.4"
 | 
			
		||||
  },
 | 
			
		||||
@@ -22,32 +28,36 @@
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test":          "phpunit",
 | 
			
		||||
    "document":      "tools/phpDocumentor",
 | 
			
		||||
    "benchmark":     "tools/phpbench run --report=default --output=build-artifact",
 | 
			
		||||
    "metrics":       "vendor/bin/phpmetrics --config=phpmetrics.yml",
 | 
			
		||||
    "test": "phpunit",
 | 
			
		||||
    "document": [
 | 
			
		||||
      "tools/phpcs --generator=MarkDown > docs/CodeStandard.md",
 | 
			
		||||
      "tools/phpdocumentor"
 | 
			
		||||
    ],
 | 
			
		||||
    "benchmark": "tools/phpbench run --report=default --output=build-artifact",
 | 
			
		||||
    "metrics": "vendor/bin/phpmetrics --config=phpmetrics.yml",
 | 
			
		||||
    "lint": [
 | 
			
		||||
        "tools/phplint",
 | 
			
		||||
        "tools/phpcs",
 | 
			
		||||
        "tools/phpcbf  src/ tests/ benchmark/ examples/",
 | 
			
		||||
        "tools/phpmd src/,tests/,benchmark/,examples/ text phpmd.ruleset.xml"
 | 
			
		||||
      "tools/phpcs",
 | 
			
		||||
      "tools/phpcbf  src/ tests/ benchmark/ examples/",
 | 
			
		||||
      "tools/phpmd src/,tests/,benchmark/,examples/ text phpmd.ruleset.xml"
 | 
			
		||||
    ],
 | 
			
		||||
    "analyze": [
 | 
			
		||||
        "@analyze-phpstan",
 | 
			
		||||
        "@analyze-psalm",
 | 
			
		||||
        "@analyze-rector"
 | 
			
		||||
      "@analyze-phpstan",
 | 
			
		||||
      "@analyze-psalm",
 | 
			
		||||
      "@analyze-rector"
 | 
			
		||||
    ],
 | 
			
		||||
    "analyze-phpstan":"tools/phpstan analyze --error-format=raw",
 | 
			
		||||
    "analyze-psalm":  "tools/psalm --no-cache --show-info=true",
 | 
			
		||||
    "analyze-phpstan": "tools/phpstan analyze --error-format=raw",
 | 
			
		||||
    "analyze-psalm": "tools/psalm --no-cache --show-info=true",
 | 
			
		||||
    "analyze-rector": "vendor/bin/rector --dry-run",
 | 
			
		||||
    "html": [
 | 
			
		||||
      "pandoc -s README.md -o output/README.html",
 | 
			
		||||
      "pandoc -s docs/index.rst -o output/index.html"
 | 
			
		||||
      "pandoc -s docs/index.rst -o output/index.html",
 | 
			
		||||
      "pandoc -s docs/CodeStandard.md -o output/CodeStandard.html  --metadata title=\"Code Standard\""
 | 
			
		||||
    ],
 | 
			
		||||
    "all": [
 | 
			
		||||
      "@test",
 | 
			
		||||
      "@lint",
 | 
			
		||||
      "@analyze",
 | 
			
		||||
      "@document",
 | 
			
		||||
      "@metrics",
 | 
			
		||||
      "@html"
 | 
			
		||||
    ]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4317
									
								
								docs/CodeStandard.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4317
									
								
								docs/CodeStandard.md
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -33,6 +33,7 @@ Links
 | 
			
		||||
* `Test report <test/index.html>`_
 | 
			
		||||
* `Mutation testing <mutation/infection.html>`_
 | 
			
		||||
* `Code metrics <metrics/index.html>`_
 | 
			
		||||
* `Code Standard <CodeStandard.html>`_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Standard Tools
 | 
			
		||||
 
 | 
			
		||||
@@ -16,5 +16,5 @@
 | 
			
		||||
            </source>
 | 
			
		||||
        </api>
 | 
			
		||||
    </version>
 | 
			
		||||
    <!--setting name="graphs.enabled" value="true"/-->
 | 
			
		||||
    <setting name="graphs.enabled" value="true"/>
 | 
			
		||||
</phpdocumentor>
 | 
			
		||||
@@ -24,7 +24,7 @@ abstract class FactorGraphLayer
 | 
			
		||||
     */
 | 
			
		||||
    private array $inputVariablesGroups = [];
 | 
			
		||||
 | 
			
		||||
    protected function __construct(private readonly TrueSkillFactorGraph $parentFactorGraph)
 | 
			
		||||
    public function __construct(private readonly TrueSkillFactorGraph $parentFactorGraph)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ final class BasicMath
 | 
			
		||||
    /**
 | 
			
		||||
     * Sums the items in $itemsToSum
 | 
			
		||||
     *
 | 
			
		||||
     * @param mixed[]    $itemsToSum The items to sum,
 | 
			
		||||
     * @param mixed[]    $itemsToSum The items to sum.
 | 
			
		||||
     * @param \Closure $callback   The function to apply to each array element before summing.
 | 
			
		||||
     *
 | 
			
		||||
     * @return float The sum.
 | 
			
		||||
 
 | 
			
		||||
@@ -34,8 +34,9 @@ final class GaussianDistribution
 | 
			
		||||
     */
 | 
			
		||||
    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)
 | 
			
		||||
    /**
 | 
			
		||||
     * Precision and precisionMean are used because they make multiplying and dividing simpler.
 | 
			
		||||
     */
 | 
			
		||||
    private float $precision = 1.0;
 | 
			
		||||
 | 
			
		||||
    private float $precisionMean = 0.0;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,14 +13,20 @@ final readonly class Player implements ISupportPartialPlay, ISupportPartialUpdat
 | 
			
		||||
 | 
			
		||||
    private const float DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var float The weight percentage to give this player when calculating a new rank.
 | 
			
		||||
     */
 | 
			
		||||
    private float $PartialPlayPct;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var float Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
 | 
			
		||||
     */
 | 
			
		||||
    private float $PartialUpdatePct;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param string|int $Id                      The identifier for the player, such as a name.
 | 
			
		||||
     * @param string|int $Id          The identifier for the player, such as a name.
 | 
			
		||||
     * @param float $partialPlayPct   The weight percentage to give this player when calculating a new rank.
 | 
			
		||||
     * @param float $partialUpdatePct Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,9 @@ namespace DNW\Skills;
 | 
			
		||||
 | 
			
		||||
class RatingContainer
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Link Player to a Rating using a hash map.
 | 
			
		||||
     */
 | 
			
		||||
    private readonly HashMap $playerToRating;
 | 
			
		||||
 | 
			
		||||
    public function __construct()
 | 
			
		||||
 
 | 
			
		||||
@@ -9,8 +9,4 @@ use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
 | 
			
		||||
abstract class TrueSkillFactorGraphLayer extends FactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(TrueSkillFactorGraph $parentGraph)
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct($parentGraph);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user