<?xml version="1.0"?>
<!-- See http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php -->
<ruleset name="Drupal">
  <description>Drupal coding standard</description>
  <!-- All Drupal code files must be UTF-8 encoded and we treat them as such. -->
  <arg name="encoding" value="utf-8"/>

  <rule ref="Internal.NoCodeFound">
    <!-- Empty files are fine, might be used for testing. -->
    <exclude-pattern>*</exclude-pattern>
  </rule>

  <rule ref="Drupal.Commenting.FileComment">
    <!-- Do not run this sniff on txt files. -->
    <exclude-pattern>*.txt</exclude-pattern>
  </rule>
  <rule ref="Drupal.Commenting.FileComment.SpacingAfterComment">
    <!-- Do not run this sniff on template files. -->
    <exclude-pattern>*.tpl.php</exclude-pattern>
  </rule>
  <rule ref="Drupal.ControlStructures.ControlSignature">
    <!-- Do not run this sniff on template files. -->
    <exclude-pattern>*.tpl.php</exclude-pattern>
  </rule>

  <!-- Silence deprecated sniffs that will be removed in Coder 9.x. -->
  <rule ref="Drupal.Functions.FunctionDeclaration.SpaceAfter">
    <severity>0</severity>
  </rule>
  <rule ref="Drupal.Functions.FunctionDeclaration.SpaceBeforeParenthesis">
    <severity>0</severity>
  </rule>

  <!-- Silence method name underscore warning which is covered already in
       Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps. -->
  <rule ref="Drupal.Methods.MethodDeclaration.Underscore">
    <severity>0</severity>
  </rule>

  <rule ref="Drupal.WhiteSpace.ScopeIndent">
    <!-- Do not run this sniff on template files, as the indentation might follow
         the HTML -->
    <exclude-pattern>*.tpl.php</exclude-pattern>
  </rule>
  <rule ref="Drupal.WhiteSpace.ScopeClosingBrace">
    <!-- Do not run this sniff on template files, as the indentation might follow
         the HTML -->
    <exclude-pattern>*.tpl.php</exclude-pattern>
  </rule>

  <!-- Generic sniffs -->
  <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
  <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
  <rule ref="Generic.Files.ByteOrderMark"/>
  <rule ref="Generic.Files.LineEndings"/>
  <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
  <rule ref="Generic.Formatting.SpaceAfterCast"/>
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
  <!-- Already covered by Drupal.WhiteSpace.Comma.NoSpace. -->
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma">
    <severity>0</severity>
  </rule>
  <rule ref="Generic.NamingConventions.ConstructorName"/>
  <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
  <rule ref="Generic.PHP.DisallowShortOpenTag">
    <!-- Do not run this sniff on .yml files -->
    <exclude-pattern>*.yml</exclude-pattern>
  </rule>
  <rule ref="Generic.PHP.LowerCaseKeyword"/>
  <rule ref="Generic.PHP.UpperCaseConstant"/>
  <rule ref="Generic.Strings.UnnecessaryStringConcat">
    <properties>
      <property name="allowMultiline" value="true"/>
    </properties>
  </rule>
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
  <rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>

  <!-- PEAR sniffs -->
  <rule ref="PEAR.Files.IncludingFile"/>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="PEAR.Files.IncludingFile.UseInclude">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequire">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature"/>
  <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.OpeningIndent">
    <severity>0</severity>
  </rule>
  <!-- Disable some error messages that we already cover. -->
  <rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.ValidDefaultValue"/>

  <!-- PSR-2 sniffs -->
  <rule ref="PSR2.Classes.PropertyDeclaration">
     <!-- Already covered by Drupal.Classes.PropertyDeclaration.VarUsed. -->
    <exclude name="PSR2.Classes.PropertyDeclaration.VarUsed"/>
  </rule>
  <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
  <rule ref="PSR2.Namespaces.UseDeclaration"/>

  <!-- SlevomatCodingStandard sniffs -->
  <rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
  <rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
    <properties>
       <property name="forbiddenCommentPatterns" type="array">
         <!-- Catch comments ending in 2 dots, bot leave comments ending in 3
         dots alone. -->
         <element value="/(?&lt;!\.)\.\.(?!\.)$/"/>
       </property>
    </properties>
  </rule>
  <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
  <rule ref="SlevomatCodingStandard.PHP.ShortList"/>
  <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
    <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing"/>
    <properties>
      <property name="linesCountBeforeDeclare" value="1"/>
      <property name="linesCountAfterDeclare" value="1"/>
      <property name="spacesCountAroundEqualsSign" value="0"/>
    </properties>
  </rule>
  <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>

  <rule ref="Squiz.Arrays.ArrayDeclaration"/>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
    <severity>0</severity>
  </rule>

  <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>

  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
  <!-- Disable some error messages that we already cover. -->
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
  <!-- Disable some error messages that we already cover. -->
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
    <severity>0</severity>
  </rule>

  <rule ref="Squiz.ControlStructures.SwitchDeclaration"/>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.BreakIndent">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.CaseIndent">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.CloseBraceAlign">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.DefaultIndent">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.DefaultNoBreak">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.EmptyCase">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.EmptyDefault">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.MissingDefault">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingAfterCase">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingAfterDefaultBreak">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.ControlStructures.SwitchDeclaration.SpacingBeforeBreak">
    <severity>0</severity>
  </rule>

  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
    <properties>
      <property name="equalsSpacing" value="1"/>
    </properties>
  </rule>
  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
    <severity>0</severity>
  </rule>

  <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
  <rule ref="Squiz.PHP.NonExecutableCode"/>
  <rule ref="Squiz.Strings.ConcatenationSpacing">
    <properties>
      <property name="spacing" value="1"/>
      <property name="ignoreNewlines" value="true"/>
    </properties>
  </rule>
  <rule ref="Squiz.WhiteSpace.FunctionSpacing">
    <properties>
      <property name="spacing" value="1"/>
    </properties>
  </rule>
  <rule ref="Squiz.WhiteSpace.OperatorSpacing">
    <properties>
      <property name="ignoreNewlines" value="true"/>
    </properties>
  </rule>
  <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
  <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
  <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>

  <rule ref="Zend.Files.ClosingTag">
    <!-- Do not run this sniff on template files. -->
    <exclude-pattern>*.tpl.php</exclude-pattern>
  </rule>

  <!-- Ignore various version control directories. -->
  <exclude-pattern>*/\.git/*</exclude-pattern>
  <exclude-pattern>*/\.svn/*</exclude-pattern>
  <exclude-pattern>*/\.hg/*</exclude-pattern>
  <exclude-pattern>*/\.bzr/*</exclude-pattern>
</ruleset>
