phpcs.xml 2.61 KB
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="droopler">
    <description>PHP CodeSniffer configuration for a Drupal module.</description>

    <arg name="extensions" value="php,inc,install,module,info,test,profile,theme,yaml,txt,twig,scss"/>

    <arg name="report" value="full,gitblame"/>

    <config name="installed_paths" value="../../drupal/coder/coder_sniffer/Drupal,../../drupal/coder/coder_sniffer/DrupalPractice,../../slevomat/coding-standard" />

    <file>/app/web/modules/custom</file>
    <file>/app/web/themes/custom</file>

    <!-- Exclude third party libraries. -->
    <exclude-pattern>/.ddev</exclude-pattern>
    <exclude-pattern>/.lando</exclude-pattern>
    <exclude-pattern>*/vendor/*</exclude-pattern>
    <exclude-pattern>*/node_modules/*</exclude-pattern>
    <exclude-pattern>*/themes/custom/*/build/*</exclude-pattern>

    <rule ref="Drupal" />
    <rule ref="DrupalPractice" />

     <!-- Require the strict types declaration in every PHP file. -->
    <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
    </rule>

    <!-- Require nullable types to be declared as such. -->
    <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue">
    </rule>

    <!-- Forbid annotations which are not included in the Drupal coding standard but are often added by IDEs. -->
    <rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
        <properties>
            <property name="forbiddenAnnotations" type="array">
                <element value="@author"/>
                <element value="@created"/>
                <element value="@copyright"/>
                <element value="@license"/>
                <element value="@package"/>
                <element value="@version"/>
            </property>
        </properties>
    </rule>

    <!-- Forbid documentation auto-generated by IDEs which does not align with the Drupal documentation standards. -->
    <rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
        <properties>
            <property name="forbiddenCommentPatterns" type="array">
                <element value="/@inheritDoc/"/>
                <element value="/^Class [a-zA-z]*\.$/"/>
                <element value="/^Interface [a-zA-z]*\.$/"/>
                <element value="/^[a-zA-z]* constructor\.$/"/>
            </property>
        </properties>
    </rule>

    <!-- Enforce correct formatting of return types hints. -->
    <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>

    <!-- Use statements should be ordered alphabetically. -->
    <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
</ruleset>