<?xml version="1.0"?>
<ruleset name="WpSettingsApi">
    <description>The WpSettingsApi coding standard.</description>

    <!-- What to scan -->
    <file>src</file>
    <!-- Exclude the tests directory. -->
    <exclude-pattern>*/tests/*</exclude-pattern>
    <!-- Third-party code -->
    <exclude-pattern>*/bower-components/*</exclude-pattern>
    <exclude-pattern>*/node_modules/*</exclude-pattern>
    <exclude-pattern>*/vendor/*</exclude-pattern>
    <!-- Ensure certain file types aren't sniffed -->
    <exclude-pattern>*.js</exclude-pattern>
    <exclude-pattern>*.css</exclude-pattern>

    <!-- How to scan -->
    <arg value="sp"/> <!-- Show sniff and progress -->
    <arg name="basepath" value="."/><!-- Strip the file paths down to the relevant bit -->
    <arg name="colors"/>
    <arg name="extensions" value="php"/>
    <arg name="tab-width" value="4"/>
    <!-- For CI, don't fail on warnings -->
    <config name="ignore_warnings_on_exit" value="1"/>
    <!-- Sets the minimum supported WP version -->
    <config name="minimum_supported_wp_version" value="6.4"/>
    <!-- Check for cross-version support for PHP 8.0 and higher. -->
    <config name="testVersion" value="8.0-"/>

    <rule ref="WordPress-Docs">
        <exclude name="Generic.Commenting.DocComment.SpacingBeforeTags"/>
        <exclude name="Squiz.Commenting.FileComment.Missing"/>
        <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
        <exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/>
        <exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop"/>
        <exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
        <exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
        <exclude name="Squiz.Commenting.VariableComment.Missing"/>
    </rule>

    <rule ref="WordPress.WP.I18n">
        <properties>
            <property name="text_domain" type="array" value="wp-settings-api"/>
        </properties>
        <exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
    </rule>

    <!--    DISABLED UNTIL THEY SUPPORT squizlabs/php_codesniffer > 3.6.0-->
    <!--    <rule ref="Inpsyde">-->
    <!--        <exclude name="Generic.Metrics.NestingLevel.TooHigh"/>-->
    <!--        <exclude name="Inpsyde.CodeQuality.FunctionBodyStart.WrongForMultiLineDeclaration"/>-->
    <!--        <exclude name="Inpsyde.CodeQuality.LineLength.TooLong"/>-->
    <!--        <exclude name="Inpsyde.CodeQuality.NoAccessors.NoGetter"/>-->
    <!--        <exclude name="Inpsyde.CodeQuality.NoAccessors.NoSetter"/>-->
    <!--        <exclude name="Inpsyde.CodeQuality.VariablesName.SnakeCaseVar"/>-->
    <!--        <exclude name="NeutronStandard.Functions.DisallowCallUserFunc.CallUserFunc"/>-->
    <!--        <exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>-->
    <!--    </rule>-->
    <!--    <rule ref="Inpsyde.CodeQuality.NestingLevel">-->
    <!--        <properties>-->
    <!--            <property name="errorLimit" value="10"/>-->
    <!--            <property name="warningLimit" value="5"/>-->
    <!--        </properties>-->
    <!--    </rule>-->
    <!--    <rule ref="Inpsyde.CodeQuality.PropertyPerClassLimit">-->
    <!--        <properties>-->
    <!--            <property name="maxCount" value="20"/>-->
    <!--        </properties>-->
    <!--    </rule>-->

    <rule ref="PSR12">
        <exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
        <exclude name="PSR12.Files.FileHeader.IncorrectOrder"/>
        <exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
        <exclude name="PSR12.Files.OpenTag.NotAlone"/>
        <exclude name="PSR12.Traits.UseDeclaration.MultipleImport"/>
        <exclude name="PSR12.Traits.UseDeclaration.UseAfterBrace"/>
    </rule>

    <rule ref="Generic.Arrays.ArrayIndent"/>
    <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
        <severity>0</severity>
    </rule>

    <!-- Slevomat (selective) Coding Standards -->
    <rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
    <rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
    <rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
    <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
    <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
    <rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
    <rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
    <rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
    <rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition">
        <properties>
            <property name="ignoreAssignmentsInsideFunctionCalls" value="true"/>
        </properties>
    </rule>
    <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
    <rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
    <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
    <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
    <rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
    <rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
    <rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
    <rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
    <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
    <rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
    <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
    <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse"/>
    <rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
    <rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
    <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
    <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
    <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
        <exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation"/>
    </rule>
    <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
        <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
        <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation"/>
    </rule>
    <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
    <rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>

    <!-- Loads the PHP Compatibility ruleset. -->
    <rule ref="PHPCompatibility"/>
</ruleset>
