phpcs.xml.dist 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?xml version="1.0"?>
  2. <ruleset name="PHP_CodeSniffer">
  3. <description>The coding standard for PHP_CodeSniffer itself.</description>
  4. <file>autoload.php</file>
  5. <file>bin</file>
  6. <file>scripts</file>
  7. <file>src</file>
  8. <file>tests</file>
  9. <exclude-pattern>*/Standards/*/Tests/*\.(inc|css|js)</exclude-pattern>
  10. <arg name="basepath" value="."/>
  11. <arg name="colors" />
  12. <arg name="parallel" value="75" />
  13. <arg value="np"/>
  14. <!-- Don't hide tokenizer exceptions -->
  15. <rule ref="Internal.Tokenizer.Exception">
  16. <type>error</type>
  17. </rule>
  18. <!-- Include the whole PEAR standard -->
  19. <rule ref="PEAR">
  20. <exclude name="PEAR.NamingConventions.ValidFunctionName" />
  21. <exclude name="PEAR.NamingConventions.ValidVariableName" />
  22. <exclude name="PEAR.Commenting.ClassComment" />
  23. <exclude name="PEAR.Commenting.FileComment.MissingCategoryTag" />
  24. <exclude name="PEAR.Commenting.FileComment.MissingPackageTag" />
  25. <exclude name="PEAR.Commenting.FileComment.MissingLinkTag" />
  26. <exclude name="PEAR.Commenting.FileComment.MissingVersion" />
  27. <exclude name="PEAR.Commenting.InlineComment" />
  28. </rule>
  29. <!-- Include some sniffs from other standards that don't conflict with PEAR -->
  30. <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
  31. <rule ref="Squiz.Arrays.ArrayDeclaration" />
  32. <rule ref="Squiz.Commenting.ClosingDeclarationComment" />
  33. <rule ref="Squiz.ControlStructures.ControlSignature" />
  34. <rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
  35. <rule ref="Squiz.Commenting.BlockComment" />
  36. <rule ref="Squiz.Commenting.DocCommentAlignment" />
  37. <rule ref="Squiz.Commenting.EmptyCatchComment" />
  38. <rule ref="Squiz.Commenting.InlineComment" />
  39. <rule ref="Squiz.Commenting.LongConditionClosingComment" />
  40. <rule ref="Squiz.Commenting.PostStatementComment" />
  41. <rule ref="Squiz.Commenting.VariableComment" />
  42. <rule ref="Squiz.Formatting.OperatorBracket" />
  43. <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing" />
  44. <rule ref="Squiz.Operators.ComparisonOperatorUsage" />
  45. <rule ref="Squiz.PHP.DisallowInlineIf" />
  46. <rule ref="Squiz.Scope.MethodScope" />
  47. <rule ref="Squiz.Strings.ConcatenationSpacing" />
  48. <rule ref="Squiz.WhiteSpace.ControlStructureSpacing" />
  49. <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace" />
  50. <rule ref="Squiz.WhiteSpace.FunctionSpacing" />
  51. <rule ref="Squiz.WhiteSpace.OperatorSpacing" />
  52. <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
  53. <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
  54. <rule ref="Generic.Commenting.Todo"/>
  55. <rule ref="Generic.ControlStructures.InlineControlStructure"/>
  56. <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
  57. <rule ref="Generic.Formatting.SpaceAfterCast"/>
  58. <rule ref="Generic.NamingConventions.ConstructorName"/>
  59. <rule ref="Generic.PHP.DeprecatedFunctions"/>
  60. <rule ref="Generic.PHP.LowerCaseKeyword"/>
  61. <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
  62. <rule ref="PSR2.Classes.PropertyDeclaration"/>
  63. <rule ref="PSR2.Methods.MethodDeclaration"/>
  64. <rule ref="PSR2.Files.EndFileNewline"/>
  65. <rule ref="Zend.Files.ClosingTag"/>
  66. <!-- PEAR uses warnings for inline control structures, so switch back to errors -->
  67. <rule ref="Generic.ControlStructures.InlineControlStructure">
  68. <properties>
  69. <property name="error" value="true"/>
  70. </properties>
  71. </rule>
  72. <!-- We use custom indent rules for arrays -->
  73. <rule ref="Generic.Arrays.ArrayIndent"/>
  74. <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
  75. <severity>0</severity>
  76. </rule>
  77. <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
  78. <severity>0</severity>
  79. </rule>
  80. <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
  81. <severity>0</severity>
  82. </rule>
  83. <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
  84. <severity>0</severity>
  85. </rule>
  86. <!-- Check var names, but we don't want leading underscores for private vars -->
  87. <rule ref="Squiz.NamingConventions.ValidVariableName" />
  88. <rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
  89. <severity>0</severity>
  90. </rule>
  91. <!-- Only one argument per line in multi-line function calls -->
  92. <rule ref="PEAR.Functions.FunctionCallSignature">
  93. <properties>
  94. <property name="allowMultipleArguments" value="false"/>
  95. </properties>
  96. </rule>
  97. <!-- Have 12 chars padding maximum and always show as errors -->
  98. <rule ref="Generic.Formatting.MultipleStatementAlignment">
  99. <properties>
  100. <property name="maxPadding" value="12"/>
  101. <property name="error" value="true"/>
  102. </properties>
  103. </rule>
  104. <!-- Ban some functions -->
  105. <rule ref="Generic.PHP.ForbiddenFunctions">
  106. <properties>
  107. <property name="forbiddenFunctions" type="array">
  108. <element key="sizeof" value="count"/>
  109. <element key="delete" value="unset"/>
  110. <element key="print" value="echo"/>
  111. <element key="is_null" value="null"/>
  112. <element key="create_function" value="null"/>
  113. </property>
  114. </properties>
  115. </rule>
  116. <!-- Private methods MUST not be prefixed with an underscore -->
  117. <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
  118. <type>error</type>
  119. </rule>
  120. <!-- Private properties MUST not be prefixed with an underscore -->
  121. <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
  122. <type>error</type>
  123. </rule>
  124. <!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
  125. <rule ref="Generic.Strings.UnnecessaryStringConcat">
  126. <exclude-pattern>tests/bootstrap.php</exclude-pattern>
  127. </rule>
  128. </ruleset>