<?xml version="1.0"?>
<ruleset name="PHPCodingStandards">
    <description>PHP coding standards.</description>

    <file>./</file>
    <exclude-pattern>ui/</exclude-pattern>
    <exclude-pattern>vendor/</exclude-pattern>
    <exclude-pattern>libs/</exclude-pattern>

    <!-- Extend a base coding standard, such as PSR12 -->
    <rule ref="PSR12"/>

    <!-- Disallow Yoda conditions -->
    <rule ref="Generic.ControlStructures.DisallowYodaConditions"/>

    <!-- Enforce brace placement for function declarations -->
    <rule ref="PSR12">
        <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
    </rule>
    <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>

    <!-- Enforce brace placement for class declarations -->
    <rule ref="PSR12">
        <exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
    </rule>
    <rule ref="Generic.Classes.OpeningBraceSameLine"/>

    <!-- Prevent alignment sniffs from flagging aligned code -->
    <rule ref="PSR12">
        <exclude name="Generic.Files.LineLength.TooLong"/>
    </rule>

    <!-- Enforce camelCase for local variables -->
    <rule ref="Squiz.NamingConventions.ValidFunctionName"/>
    <rule ref="Squiz.NamingConventions.ValidVariableName"/>

    <rule ref="PSR12">
        <exclude name="Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore"/>
        <exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
        <exclude name="Squiz.NamingConventions.ValidFunctionName.PublicHasUnderscor"/>
        <exclude name="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
        <exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
        <exclude name="Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase"/>
    </rule>

    <!-- Enforce no spaces after `[/(` and before `]/)` -->
    <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
    <rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>

    <!-- Name php, js and html files in CamelCase -->

</ruleset>
