<?xml version="1.0"?>
<ruleset name="Infinum" namespace="Infinum">
  <description>Infinum coding standards for WordPress</description>

  <autoload>../autoload.php</autoload>

  <config name="encoding" value="utf-8"/>

  <!-- Check code for cross-version PHP compatibility. -->
  <config name="testVersion" value="7.1-"/>
  <rule ref="PHPCompatibilityWP"/>

  <!-- Exclude certain patterns -->
  <exclude-pattern>/vendor/*</exclude-pattern>
  <exclude-pattern>/node_modules/*</exclude-pattern>
  <exclude-pattern>*/data/*</exclude-pattern>
  <exclude-pattern>*/tests/*</exclude-pattern>
  <exclude-pattern>*.js</exclude-pattern>
  <exclude-pattern>*.css</exclude-pattern>

  <!-- Only check php code, linters are used for checking js and css -->
  <arg name="extensions" value="php"/>

  <!-- Enable colors in report -->
  <arg name="colors"/>

  <!-- Add source codes in the report -->
  <arg value="s"/>

  <!-- Tabs should represent 2 spaces. -->
  <arg name="tab-width" value="2" />

  <!-- Check against minimum WP version. -->
  <config name="minimum_supported_wp_version" value="4.7"/>

  <!-- Load WordPress Coding standards -->
  <rule ref="WordPress-Core"/>
  <rule ref="WordPress-Docs"/>
  <rule ref="WordPress-Extra"/>

  <!-- Add checking for unused function parameters. -->
  <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>

  <!-- Ignore direct DB queries rule -->
  <rule ref="WordPress.DB.DirectDatabaseQuery">
    <severity>0</severity>
  </rule>

  <!-- Don't use Yoda conditions -->
  <rule ref="WordPress.PHP.YodaConditions">
    <severity>0</severity>
  </rule>

  <!-- Ignore translators style warning  -->
  <rule ref="WordPress.WP.I18n.TranslatorsCommentWrongStyle">
    <severity>0</severity>
  </rule>

  <!-- Ignore translators comment missing  -->
  <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
    <severity>0</severity>
  </rule>

  <!-- Ignore whitespace precision alignment  -->
  <rule ref="WordPress.WhiteSpace.PrecisionAlignment">
    <severity>0</severity>
  </rule>

  <!-- Ignore multiple statement alignment  -->
  <rule ref="WordPress.Arrays.MultipleStatementAlignment">
    <severity>0</severity>
  </rule>

  <!-- Ignore space indent error  -->
  <rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
    <severity>0</severity>
  </rule>

  <!-- Ignore rule about enqueueing scripts in the footer -->
  <rule ref="WordPress.WP.EnqueuedResourceParameters.NotInFooter">
    <severity>0</severity>
  </rule>

  <!-- Modify post per page limit -->
  <rule ref="WordPress.WP.PostsPerPage">
    <properties>
      <property name="posts_per_page" value="1000"/>
    </properties>
  </rule>

  <!-- Set the default indent value and force spaces instead of tabs -->
  <rule ref="WordPress.Arrays.ArrayIndentation">
    <properties>
      <property name="tabIndent" value="false"/>
    </properties>
  </rule>

  <!-- Exclude WordPress array indentation because it forced 4 space indentation -->
  <rule ref="WordPress.Arrays.MultipleStatementAlignment">
    <properties>
      <property name="alignMultilineItems" value="!=100"/>
    </properties>
  </rule>

  <!-- Exclude the multiline array indentation sniff,
  because it clashes with Generic indentation sniff -->
  <rule ref="WordPress.Arrays.ArrayIndentation">
    <severity>0</severity>
  </rule>

  <rule ref="Generic.WhiteSpace.ScopeIndent">
    <properties>
      <property name="indent" value="2"/>
      <property name="tabIndent" value="false"/>
    </properties>
  </rule>

  <!-- Rule that will correctly indent arrays -->
  <rule ref="Generic.Arrays.ArrayIndent">
    <properties>
      <property name="indent" value="2" />
    </properties>
  </rule>

  <rule ref="Generic.WhiteSpace.DisallowTabIndent" />

  <!-- Function parameters have to have a space before opening
  and after closing braces. Also the default indentaion of properties is 2 spaces -->
  <rule ref="PEAR.Functions.FunctionCallSignature">
    <properties>
      <property name="indent" value="2"/>
      <property name="requiredSpacesAfterOpen" value="1" />
      <property name="requiredSpacesBeforeClose" value="1" />
    </properties>
  </rule>

  <!-- Set minimum supported version for deprecated functions -->
  <rule ref="WordPress.WP.DeprecatedFunctions">
    <properties>
      <property name="minimum_supported_version" value="4.7" />
    </properties>
  </rule>

  <!-- Allow theme hierarchy specific file name exceptions -->
  <rule ref="WordPress.Files.FileName">
    <properties>
      <property name="is_theme" value="true" />
    </properties>
  </rule>

  <!-- Disallow _ in file names, except in a certain files -->
  <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
    <exclude-pattern>*/sections/*</exclude-pattern>
  </rule>

  <!-- Forbidden space after function keyword and open parenthesis -->
  <rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
    <properties>
      <property name="spaces_before_closure_open_paren" value="0" />
    </properties>
  </rule>

  <!-- Ignore unused parameters in functions on account on hooks -->
  <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter.Found">
    <severity>0</severity>
  </rule>

  <!-- Private methods MUST not be prefixed with an underscore -->
  <rule ref="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore">
      <severity>0</severity>
  </rule>
  <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
      <type>error</type>
  </rule>

  <!-- Private properties MUST not be prefixed with an underscore -->
  <rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
      <severity>0</severity>
  </rule>
  <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
      <type>error</type>
  </rule>

  <!-- Don't worry about files that don't contain any code -->
  <rule ref="Internal.NoCodeFound">
    <severity>0</severity>
  </rule>
</ruleset>
