<?xml version="1.0"?>
<ruleset name="Coding Standard">
    <description>Coding Standard</description>
    <config name="installed_paths" value="../../slevomat/coding-standard"/>

    <!-- display progress -->
    <arg value="p"/>
    <arg name="colors"/>

    <!-- Paths to check -->
    <file>src</file>

    <!-- Generic rules -->
    <rule ref="PSR12"/>
    <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
        <properties>
            <property name="ignoreBlankLines" value="false"/>
        </properties>
    </rule>

    <rule ref="Generic.Files.LineLength">
        <properties>
            <property name="lineLimit" value="240"/>
            <property name="absoluteLineLimit" value="320"/>
        </properties>
    </rule>

    <!-- Functional rules -->
    <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
        <properties>
            <property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
            <property name="newlinesCountAfterDeclare" value="2"/>
            <property name="spacesCountAroundEqualsSign" value="0"/>
        </properties>
    </rule>
    <rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
    <rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
    <rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>

    <!-- Rules for detecting dead or useless code -->
    <rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
    <rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
    <rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
    <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
    <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
    <rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
    <rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
    <rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
    <rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
    <rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
    <rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
    <rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>

    <!-- Rules for consistent code looks -->
    <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>

    <!-- 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="is_null" value="null"/>
                <element key="create_function" value="null"/>
            </property>
        </properties>
    </rule>
</ruleset>
