<?xml version="1.0"?>
<ruleset name="Asalae">
    <description>Asalae coding standard</description>

    <rule ref="PSR2"/>
    <rule ref="Generic.Arrays.ArrayIndent"/>
    <rule ref="PEAR.Classes"/>
    <rule ref="PEAR.Commenting.FunctionComment"/>
    <rule ref="PEAR.Commenting.FunctionComment.MissingParamTag"/>
    <!-- pas besoin de commentaire sur chaques paramètres de fonction -->
    <rule ref="PEAR.Commenting.FunctionComment.MissingParamComment">
        <severity>0</severity>
    </rule>
    <rule ref="PEAR.Commenting.FunctionComment.ContentAfterOpen"/>
    <rule ref="PEAR.Commenting.FunctionComment.ContentBeforeClose"/>
    <rule ref="PEAR.ControlStructures"/>
    <rule ref="PEAR.Files"/>
    <rule ref="PEAR.Formatting"/>
    <rule ref="PEAR.Functions"/>
    <rule ref="PEAR.Functions.FunctionCallSignature"/>

    <!-- espacement des arguments de fonction -->
    <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
    <!-- les constantes doivent être complètement en majuscules -->
    <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
    <rule ref="Generic.PHP.LowerCaseConstant"/>
    <!-- "<?php" oui, "<?" non -->
    <rule ref="Generic.PHP.DisallowShortOpenTag"/>
    <!-- indentation avec des espaces (pas de tabulation) -->
    <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
    <!-- phpdoc bien aligné -->
    <rule ref="Squiz.Commenting.DocCommentAlignment"/>
    <!-- retour à la ligne en fin de document -->
    <rule ref="Generic.Files.LineEndings">
        <properties>
            <property name="eolChar" value="\n"/>
        </properties>
    </rule>
    <!-- interdit plus de 1 espace après une virgule -->
    <rule ref="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma">
        <severity>0</severity>
    </rule>
    <!-- interdit les if sans accolades -->
    <rule ref="Generic.ControlStructures.InlineControlStructure">
        <properties>
            <property name="error" value="false"/>
        </properties>
    </rule>
    <!-- interdit les fonctions trop complexes -->
    <rule ref="Generic.Metrics.CyclomaticComplexity">
        <properties>
            <property name="complexity" value="20"/>
            <property name="absoluteComplexity" value="30"/>
        </properties>
    </rule>
    <!-- interdit une profondeur trop élevée ex: else { if() { foreach () { try() { if()  -->
    <rule ref="Generic.Metrics.NestingLevel">
        <properties>
            <property name="nestingLevel" value="4"/>
            <property name="absoluteNestingLevel" value="5"/>
        </properties>
    </rule>

    <!-- Autorise les préfixes "_" pour les fonctions et propriétés protected/private (convention cakephp) -->
    <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
        <severity>0</severity>
    </rule>
    <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
        <severity>0</severity>
    </rule>
    <rule ref="PEAR.NamingConventions.ValidFunctionName.PublicUnderscore">
        <severity>0</severity>
    </rule>
    <rule ref="PEAR.Commenting.FunctionComment.MissingReturn">
        <severity>0</severity>
    </rule>
</ruleset>