<?xml version="1.0"?>
<ruleset name="BitApps/wpp">
    <description>Coding standard used for wp plugin dev.</description>
    <exclude-pattern>*/tests/*</exclude-pattern>
    <exclude-pattern>tests.*</exclude-pattern>
    <exclude-pattern>*/vendor/*</exclude-pattern>
    <exclude-pattern type="relative">^/frontend/*</exclude-pattern>
    <rule ref="Internal.Tokenizer.Exception">
        <type>error</type>
    </rule>

    <!-- Include the whole PEAR standard -->
    <rule ref="PEAR">
        <exclude name="PEAR.NamingConventions.ValidFunctionName" />
        <exclude name="PEAR.NamingConventions.ValidVariableName" />
        <exclude name="PEAR.Commenting.ClassComment" />
        <exclude name="PEAR.Commenting.FileComment" />
        <exclude name="PEAR.WhiteSpace.ScopeIndent" />
        <!-- <exclude name="PEAR.Commenting.FileComment.Missing" /> -->
        <exclude name="PEAR.Commenting.FunctionComment" />
        <!-- <exclude name="PEAR.Commenting.FunctionComment.MissingParamComment" /> -->
        <!-- <exclude name="PEAR.Commenting.FileComment.MissingCategoryTag" />
        <exclude name="PEAR.Commenting.FileComment.MissingPackageTag" />
        <exclude name="PEAR.Commenting.FileComment.MissingLinkTag" />
        <exclude name="PEAR.Commenting.FileComment.MissingVersion" /> -->
        <exclude name="PEAR.Commenting.InlineComment" />
        <exclude name="PEAR.ControlStructures.MultiLineCondition" />
    </rule>

    <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
    <rule ref="Squiz.Arrays.ArrayDeclaration" />
    <rule ref="Squiz.ControlStructures.ControlSignature" />
    <rule ref="Squiz.Formatting.OperatorBracket">
        <exclude name="Squiz.Formatting.OperatorBracket.MissingBrackets" />
    </rule>
    <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
        <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals" />
        <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterEquals" />
    </rule>
    <rule ref="Squiz.Scope.MethodScope" />
    <rule ref="Squiz.WhiteSpace.ControlStructureSpacing">
        <exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace" />
    </rule>
    <rule ref="Squiz.WhiteSpace.MemberVarSpacing">
        <exclude name="Squiz.WhiteSpace.MemberVarSpacing.FirstIncorrect" />
    </rule>
    <rule ref="Squiz.WhiteSpace.OperatorSpacing">
        <exclude name="Squiz.WhiteSpace.OperatorSpacing.SpacingBefore" />
    </rule>
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
    <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.NamingConventions.ConstructorName" />
    <rule ref="Generic.PHP.DeprecatedFunctions" />
    <rule ref="Generic.PHP.LowerCaseKeyword" />
    <rule ref="Generic.Strings.UnnecessaryStringConcat" />
    <rule ref="Generic.WhiteSpace.IncrementDecrementSpacing" />
    <rule ref="PSR2.Classes.PropertyDeclaration">
        <exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
    </rule>
    <rule ref="PSR2.Methods.MethodDeclaration" />
    <rule ref="PSR2.Files.EndFileNewline" />
    <rule ref="PSR12.Files.OpenTag" />
    <rule ref="Zend.Files.ClosingTag" />

    <!-- PEAR uses warnings for inline control structures, so switch back to errors -->
    <rule ref="Generic.ControlStructures.InlineControlStructure">
        <properties>
            <property name="error" value="true" />
        </properties>
    </rule>

    <rule ref="Generic.Files.LineLength">
        <properties>
            <property name="lineLimit" value="120" />
            <property name="absoluteLineLimit" value="130" />
        </properties>
    </rule>
    <!-- We use custom indent rules for arrays -->
    <rule ref="Generic.Arrays.ArrayIndent" />
    <rule ref="Squiz.Arrays.ArrayDeclaration">
        <exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed" />
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
        <severity>0</severity>
    </rule>

    <rule ref="Squiz.NamingConventions.ValidVariableName" />
    <rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps">
        <severity>0</severity>
    </rule>

    <!-- Only one argument per line in multi-line function calls -->
    <rule ref="PEAR.Functions.FunctionCallSignature">
        <properties>
            <property name="allowMultipleArguments" value="false" />
        </properties>
    </rule>
    <rule ref="Generic.Formatting.MultipleStatementAlignment">
        <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame" />
        <exclude name="Generic.Formatting.MultipleStatementAlignment.Incorrect" />
        <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
    </rule>
    <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="error_log" />
                <element key="print_r" value="error_log" />
                <element key="var_dump" value="error_log" />
                <element key="echo" value="error_log" />
                <element key="eval" value="null" />
                <element key="create_function" value="null" />
            </property>
        </properties>
    </rule>
</ruleset>