Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
phpcs.xml 7.42 KiB
<?xml version="1.0"?>
<ruleset name="Drupal coding standards">
  <description>Drupal 8 coding standards</description>

  <file>.</file>
  <arg name="extensions" value="inc,install,module,php,profile,test,theme"/>

  <!--Exclude third party code.-->
  <exclude-pattern>./vendor/*</exclude-pattern>
  <!--Run Drupal standards.-->
  <rule ref="Drupal.Array"/>
  <rule ref="Drupal.Classes"/>
  <rule ref="Drupal.Commenting">
    <!-- TagsNotGrouped and ParamGroup have false-positives.
      @see https://www.drupal.org/node/2060925 -->
    <exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
    <exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
  </rule>
  <rule ref="Drupal.ControlStructures"/>
  <rule ref="Drupal.CSS"/>
  <rule ref="Drupal.Files"/>
  <rule ref="Drupal.Formatting"/>
  <rule ref="Drupal.Functions"/>
  <rule ref="Drupal.InfoFiles"/>
  <rule ref="Drupal.Methods"/>
  <rule ref="Drupal.NamingConventions"/>
  <rule ref="Drupal.Scope"/>
  <rule ref="Drupal.Semantics"/>
  <rule ref="Drupal.Strings"/>
  <rule ref="Drupal.WhiteSpace"/>

  <!-- Drupal Practice sniffs -->
  <rule ref="DrupalPractice.Commenting"/>

  <!-- Generic sniffs -->
  <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
  <rule ref="Generic.Files.ByteOrderMark"/>
  <rule ref="Generic.Files.LineEndings"/>
  <rule ref="Generic.Formatting.SpaceAfterCast"/>
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
  <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
    <properties>
      <property name="checkClosures" value="true"/>
    </properties>
  </rule>
  <rule ref="Generic.NamingConventions.ConstructorName"/>
  <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
  <rule ref="Generic.PHP.DisallowShortOpenTag"/>
  <rule ref="Generic.PHP.LowerCaseKeyword"/>
  <rule ref="Generic.PHP.UpperCaseConstant"/>
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>

  <!-- MySource sniffs -->
  <rule ref="MySource.Debug.DebugCode"/>

  <!-- PEAR sniffs -->
  <rule ref="PEAR.Files.IncludingFile"/>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseInclude">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Files.IncludingFile.UseRequire">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.ValidDefaultValue"/>

  <!-- PEAR sniffs -->
  <rule ref="PEAR.Functions.FunctionCallSignature"/>
  <!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
    also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
    from that file. -->
  <!-- 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>
  <!-- Disable some error messages that we do not want. -->
  <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
    <severity>0</severity>
  </rule>
  <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
    <severity>0</severity>
  </rule>

  <!-- PSR-2 sniffs -->
  <rule ref="PSR2.Classes.PropertyDeclaration">
    <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
  </rule>
  <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
  <rule ref="PSR2.Namespaces.UseDeclaration">
    <exclude name="PSR2.Namespaces.UseDeclaration.UseAfterNamespace"/>
  </rule>

  <!-- Squiz sniffs -->
  <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
  <rule ref="Squiz.Arrays.ArrayDeclaration">
    <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
    <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
  </rule>
  <!-- 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.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.Functions.MultiLineFunctionDeclaration"/>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
    <severity>0</severity>
  </rule>
  <!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
    <severity>0</severity>
  </rule>
  <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
    <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.Strings.ConcatenationSpacing">
    <properties>
      <property name="spacing" value="1"/>
      <property name="ignoreNewlines" value="true"/>
    </properties>
  </rule>
  <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
  <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
  <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>

  <!-- Zend sniffs -->
  <rule ref="Zend.Files.ClosingTag"/>

</ruleset>