<?xml version="1.0"?>
<ruleset name="Reedware">
    <description>The coding standard for Reedware PHP code.</description>

    <file>src</file>
    <file>tests</file>

    <arg name="basepath" value="."/>
    <arg name="colors" />
    <arg value="p"/>
    <arg value="s"/>

    <!-- Don't hide tokenizer exceptions -->
    <rule ref="Internal.Tokenizer.Exception">
        <type>error</type>
    </rule>

    <!-- Include the whole PSR12 standard -->
    <rule ref="PSR12">
        <exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
        <exclude name="Generic.Files.LineLength.TooLong"/>
        <exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses"/>
        <exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
        <exclude name="PSR2.Methods.FunctionCallSignature.MultipleArguments"/>
        <exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose"/>
        <exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
    </rule>

    <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
    <rule ref="Generic.Commenting.Todo"/>
    <rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
    <rule ref="Generic.ControlStructures.InlineControlStructure"/>
    <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
    <rule ref="Generic.Formatting.SpaceAfterCast"/>
    <rule ref="Generic.PHP.DeprecatedFunctions"/>
    <rule ref="Generic.PHP.LowerCaseKeyword"/>
    <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
    <rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
    <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
    <rule ref="Squiz.Commenting.DocCommentAlignment"/>
    <rule ref="Squiz.Commenting.EmptyCatchComment"/>
    <rule ref="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
    <rule ref="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
    <rule ref="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
    <rule ref="Squiz.Commenting.PostStatementComment"/>
    <rule ref="Squiz.Commenting.VariableComment"/>
    <rule ref="Squiz.ControlStructures.ControlSignature"/>
    <rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
    <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"/>
    <rule ref="Squiz.Scope.MemberVarScope"/>
    <rule ref="Squiz.Scope.MethodScope"/>
    <rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>

    <!-- Ban some functions -->
    <rule ref="Generic.PHP.ForbiddenFunctions">
        <properties>
            <property name="forbiddenFunctions" type="array">
                <element key="sizeof" value="count"/>
                <element key="delete" value="unset"/>
                <element key="print" value="echo"/>
                <element key="create_function" value="null"/>
            </property>
        </properties>
    </rule>

    <!-- Relax rules for testing -->
    <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>

    <rule ref="Squiz.Commenting.VariableComment.Missing">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>

    <rule ref="Squiz.Commenting.FunctionComment">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>

    <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>

    <rule ref="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore">
        <exclude-pattern>*/tests/*</exclude-pattern>
    </rule>

</ruleset>
