<?xml version="1.0"?>
<ruleset
    name="PHPMatrix"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
    <description>The code standard for PHPMatrix is PSR2.</description>

    <!-- ##### Coding Standard check #####-->
    <rule ref="PSR2"/>

    <!--
    #############################################################################
    COMMAND LINE ARGUMENTS
    https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
    #############################################################################
    -->

    <!-- Check all files in this directory and the directories below it. -->
    <file>.</file>

    <!-- Do not check the vendor directory. -->
    <exclude-pattern>/vendor/*</exclude-pattern>

    <!-- Show progress & sniff codes. -->
    <arg value="ps"/>
    <!-- Only check PHP files. -->
    <arg name="extensions" value="php"/>

    <!-- Strip the filepaths down to the relevant bit. -->
    <arg name="basepath" value="."/>

    <!-- Check up to 8 files simultanously. -->
    <arg name="parallel" value="8"/>


    <!--
    #############################################################################
    RULESETS
    #############################################################################
    -->

    <!-- ##### Check PHP cross-version compatibility ##### -->
    <rule ref="PHPCompatibility" />
    <config name="testVersion" value="7.2"/>

    <!--
    #############################################################################
    CUSTOMIZATIONS
    #############################################################################
    -->

    <!-- Warn about lines longer than 132 chars, and error for lines longer than 155 chars. -->
    <rule ref="Generic.Files.LineLength">
        <properties>
            <property name="lineLimit" value="132" />
            <property name="absoluteLineLimit" value="155" />
        </properties>
    </rule>


    <!--
    #############################################################################
    SELECTIVE EXCEPTIONS
    #############################################################################
    -->

    <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
        <!-- Don't break BC for integrations by renaming the autoloader methods. Not worth it. -->
        <exclude-pattern>/classes/Autoloader\.php$</exclude-pattern>
    </rule>

    <rule ref="PSR1.Classes.ClassDeclaration">
        <!-- Don't break BC for integrations by renaming the autoloader methods. Not worth it. -->
        <exclude-pattern>/classes/Bootstrap\.php$</exclude-pattern>
    </rule>

    <rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
        <!-- Exempt the bootstrap files from the side-effects rule. -->
        <exclude-pattern>/classes/Bootstrap\.php$</exclude-pattern>
        <exclude-pattern>/unitTests/bootstrap\.php$</exclude-pattern>
    </rule>

    <rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
        <exclude-pattern>/unitTests/classes/src/functions/*Test\.php$</exclude-pattern>
        <exclude-pattern>/unitTests/classes/src/operations/*Test\.php$</exclude-pattern>
    </rule>

</ruleset>
