phpcs.xml.dist 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version="1.0"?>
  2. <ruleset name="WordPress Theme Coding Standards">
  3. <!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
  4. <!-- See https://github.com/WordPress/WordPress-Coding-Standards -->
  5. <!-- See https://github.com/WPTRT/WPThemeReview -->
  6. <!-- See https://github.com/PHPCompatibility/PHPCompatibilityWP -->
  7. <!-- Set a description for this ruleset. -->
  8. <description>A custom set of code standard rules to check for WordPress themes.</description>
  9. <!--
  10. #############################################################################
  11. COMMAND LINE ARGUMENTS
  12. https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
  13. #############################################################################
  14. -->
  15. <!-- Pass some flags to PHPCS:
  16. p flag: Show progress of the run.
  17. s flag: Show sniff codes in all reports.
  18. -->
  19. <arg value="ps"/>
  20. <!-- Strip the filepaths down to the relevant bit. -->
  21. <arg name="basepath" value="./"/>
  22. <!-- Check up to 8 files simultaneously. -->
  23. <arg name="parallel" value="8"/>
  24. <!-- Check PHP files only. JavaScript and CSS files are checked separately using the @wordpress/scripts package. -->
  25. <arg name="extensions" value="php"/>
  26. <!-- Check all files in this directory and the directories below it. -->
  27. <file>.</file>
  28. <!-- Exclude patterns. -->
  29. <exclude-pattern>/vendor/*</exclude-pattern>
  30. <exclude-pattern>/node_modules/*</exclude-pattern>
  31. <!--
  32. #############################################################################
  33. USE THE WordPress AND THE Theme Review RULESET
  34. #############################################################################
  35. -->
  36. <rule ref="WordPress">
  37. <!-- This rule does not apply here since the _s prefix should be changed by the theme author. -->
  38. <exclude name="WordPress.NamingConventions.PrefixAllGlobals.ShortPrefixPassed"/>
  39. </rule>
  40. <rule ref="WPThemeReview"/>
  41. <!--
  42. #############################################################################
  43. SNIFF SPECIFIC CONFIGURATION
  44. #############################################################################
  45. -->
  46. <!-- Verify that the text_domain is set to the desired text-domain.
  47. Multiple valid text domains can be provided as a comma-delimited list. -->
  48. <rule ref="WordPress.WP.I18n">
  49. <properties>
  50. <property name="text_domain" type="array" value="_s"/>
  51. </properties>
  52. </rule>
  53. <!-- Allow for theme specific exceptions to the file name rules based
  54. on the theme hierarchy. -->
  55. <rule ref="WordPress.Files.FileName">
  56. <properties>
  57. <property name="is_theme" value="true"/>
  58. </properties>
  59. </rule>
  60. <!-- Set the minimum supported WP version. This is used by several sniffs.
  61. The minimum version set here should be in line with the minimum WP version
  62. as set in the "Requires at least" tag in the readme.txt file. -->
  63. <config name="minimum_supported_wp_version" value="4.5"/>
  64. <rule ref="WordPress.Arrays.MultipleStatementAlignment">
  65. <properties>
  66. <!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
  67. <property name="exact" value="false"/>
  68. <!-- Don't align multi-line items if ALL items in the array are multi-line. -->
  69. <property name="alignMultilineItems" value="!=100"/>
  70. <!-- Array assignment operator should always be on the same line as the array key. -->
  71. <property name="ignoreNewlines" value="false"/>
  72. </properties>
  73. </rule>
  74. <!-- Verify that everything in the global namespace is prefixed with a theme specific prefix.
  75. Multiple valid prefixes can be provided as a comma-delimited list. -->
  76. <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
  77. <properties>
  78. <property name="prefixes" type="array" value="_s" />
  79. </properties>
  80. </rule>
  81. <!--
  82. #############################################################################
  83. USE THE PHPCompatibility RULESET
  84. #############################################################################
  85. -->
  86. <config name="testVersion" value="5.6-"/>
  87. <rule ref="PHPCompatibilityWP"/>
  88. </ruleset>