<?xml version="1.0"?>
<ruleset name="OpenCart">
    <description>The Code Sniffer rule set for OpenCart</description>

    <exclude-pattern>*/system/vendor/*</exclude-pattern>

    <rule ref="Squiz.ControlStructures.InlineIfDeclaration" />

    <!-- Closing PHP tags are not allowed -->
    <rule ref="Zend.Files.ClosingTag">
        <severity>5</severity>
        <type>error</type>
    </rule>

    <!-- Test the spacing of inline control statements -->
    <rule ref="Squiz.ControlStructures.InlineIfDeclaration" />

    <!-- Check for whitespace after lines of code and checks for spaces/indents on empty lines -->
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
        <severity>1</severity>
        <type>warning</type>
    </rule>
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
    <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />

    <!-- Check to ensure no PHP deprecated functions have been used -->
    <rule ref="Generic.PHP.DeprecatedFunctions">
        <severity>5</severity>
        <type>error</type>
    </rule>

    <!-- PHP opening tag must be full <?php, no shorthand or ASP tags -->
    <rule ref="Generic.PHP.DisallowShortOpenTag">
        <severity>5</severity>
        <type>error</type>
    </rule>

    <!-- In PHP files make sure there is no character before the opening tag -->
    <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>

    <!-- true, false, null etc should all be lowercase only -->
    <rule ref="Generic.PHP.LowerCaseConstant" />

    <!-- Type casting should be immediately followed by the variable, no space -->
    <rule ref="Generic.Formatting.NoSpaceAfterCast" />

    <!-- Pass by reference is now only supported in the method/function params -->
    <rule ref="Generic.Functions.CallTimePassByReference" />

    <!-- keep the spacing between function/method params space after comma -->
    <rule ref="Generic.Functions.FunctionCallArgumentSpacing" />

    <!-- method names should always be camel case -->
    <rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>

    <!-- constants should always be uppercase -->
    <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>

    <!-- Detect BOMs to avoid curruptions -->
    <rule ref="Generic.Files.ByteOrderMark"/>

    <rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
        <exclude-pattern>*.tpl</exclude-pattern>
        <exclude-pattern>*.css</exclude-pattern>
        <exclude-pattern>*.html</exclude-pattern>
        <exclude-pattern>*.ini</exclude-pattern>
        <exclude-pattern>*.txt</exclude-pattern>
        <severity>1</severity>
        <type>warning</type>
    </rule>

    <!-- To do comments should be reported and completed -->
    <rule ref="Generic.Commenting.Todo.CommentFound">
        <message>Please review this TODO comment: %s</message>
        <severity>3</severity>
        <type>warning</type>
    </rule>

    <!-- Fix me comments should be reported and fixed -->
    <rule ref="Generic.Commenting.Todo.Fixme">
        <message>Please review this FIXME comment: %s</message>
        <severity>5</severity>
        <type>warning</type>
    </rule>

    <!-- Check that line endings are only \n -->
    <rule ref="Generic.Files.LineEndings">
        <properties>
            <property name="eolChar" value="\n"/>
        </properties>
    </rule>

    <!-- <rule ref="Squiz.ControlStructures.ControlSignature" /> -->
    <!-- <rule ref="Generic.ControlStructures.InlineControlStructure"></rule> -->

    <!-- exclude the actual tests directory from being tested! -->
    <exclude-pattern>*/tests/*</exclude-pattern>
</ruleset>

<!-- @todo - A Sniff test needs to be added to ensure short echo tags are not used -->
<!-- @todo - A Sniff test to allow helper functions (normal functions) to be snake case -->