<?xml version="1.0"?>
<ruleset name="moodle">
    <description>The Moodle coding style</description>

    <rule ref="Generic.Classes.DuplicateClassName"/>

    <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
    <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>

    <rule ref="Generic.ControlStructures.InlineControlStructure"/>

    <rule ref="Generic.Files.LineEndings"/>

    <rule ref="Generic.Functions.CallTimePassByReference"/>
    <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>

    <rule ref="Generic.NamingConventions.ConstructorName"/>
    <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>

    <rule ref="Generic.PHP.DeprecatedFunctions"/>
    <rule ref="Generic.PHP.DisallowShortOpenTag"/>
    <rule ref="Generic.PHP.LowerCaseConstant"/>

    <rule ref="Squiz.Classes.DuplicateProperty"/>
    <rule ref="Squiz.Classes.LowercaseClassKeywords"/>
    <rule ref="Squiz.Classes.SelfMemberReference"/>

    <rule ref="Generic.CodeAnalysis.EmptyStatement"/>

    <rule ref="Squiz.Commenting.DocCommentAlignment"/>
    <rule ref="Squiz.Commenting.EmptyCatchComment"/>

    <rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
    <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
    <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
    <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>

    <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>

    <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
    <rule ref="Squiz.PHP.CommentedOutCode">
        <properties>
            <property name="maxPercentage" value="40"/>
        </properties>
    </rule>

    <rule ref="Squiz.Scope.MethodScope"/>
    <rule ref="Squiz.Scope.StaticThisUsage"/>

    <rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
    <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
    <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
    <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
    <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>

    <rule ref="Zend.Files.ClosingTag"/>

    <!-- Disable this exact error unless it's approved -->
    <rule ref="moodle.Commenting.InlineComment.SpacingAfter">
        <severity>0</severity>
    </rule>

    <!-- Add the PHPCompatibility external standard
         from git://github.com/wimg/PHPCompatibility.git
         Note it only works by specifying paths. Any
         attempt to include external rulesets with own
         rules or excludes fail -->
    <rule ref="../PHPCompatibility">
        <!-- Moodle's bootstrap ensures DefaultTimezone is defined, so excluding this -->
        <exclude name="PHPCompatibility.PHP.DefaultTimezoneRequired"/>
        <!-- We use our own subclassed moodle_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff
        because there are some tokens we allow to be used as functions, like clone() -->
        <exclude name="PHPCompatibility.PHP.ForbiddenNamesAsInvokedFunctions"/>
    </rule>

</ruleset>
