| 1 |
<?xml version="1.0"?> |
| 2 |
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
| 3 |
|
| 4 |
<description>The Coding standard for the WordPress Coding Standards itself.</description> |
| 5 |
|
| 6 |
<file>.</file> |
| 7 |
|
| 8 |
<arg value="sp"/> |
| 9 |
<arg name="extensions" value="php"/> |
| 10 |
<arg name="basepath" value="."/> |
| 11 |
<arg name="parallel" value="8"/> |
| 12 |
<!-- <arg name="cache" value="false"/> --> |
| 13 |
<!-- <arg name="standard" value="WordPress"/> --> |
| 14 |
|
| 15 |
<exclude-pattern>dev-*</exclude-pattern> |
| 16 |
<exclude-pattern>node_modules/*</exclude-pattern> |
| 17 |
<exclude-pattern>vendor/*</exclude-pattern> |
| 18 |
|
| 19 |
<!-- <rule ref="WordPress"> --> |
| 20 |
<!-- <exclude name="WordPress.Files.FileName"/> --> |
| 21 |
<!-- <exclude name="WordPress.NamingConventions.ValidVariableName"/> --> |
| 22 |
<!-- <exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/> --> |
| 23 |
<!-- </rule> --> |
| 24 |
|
| 25 |
<rule ref="WordPress.Security"> |
| 26 |
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/> |
| 27 |
<exclude name="WordPress.Files.FileName"/> |
| 28 |
<exclude name="WordPress.Arrays"/> |
| 29 |
<exclude name="WordPress.NamingConventions.ValidVariableName"/> |
| 30 |
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/> |
| 31 |
</rule> |
| 32 |
<!-- Enforce PSR1 compatible namespaces. --> |
| 33 |
<!-- <rule ref="PSR1.Classes.ClassDeclaration"/> --> |
| 34 |
|
| 35 |
<!-- <rule ref="WordPress.Arrays.MultipleStatementAlignment"> --> |
| 36 |
<!-- <properties> --> |
| 37 |
<!-- <property name="alignMultilineItems" value="!=100"/> --> |
| 38 |
<!-- <property name="exact" value="false" phpcs-only="true"/> --> |
| 39 |
<!-- </properties> --> |
| 40 |
<!-- </rule> --> |
| 41 |
|
| 42 |
<rule ref="PSR2.Methods.FunctionClosingBrace"/> |
| 43 |
|
| 44 |
<!-- Check code for cross-version PHP compatibility. --> |
| 45 |
<!-- <config name="testVersion" value="5.4-"/> --> |
| 46 |
<!-- <rule ref="PHPCompatibility"> --> |
| 47 |
<!-- Exclude PHP constants back-filled by PHPCS. --> |
| 48 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_finallyFound"/> --> |
| 49 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_yieldFound"/> --> |
| 50 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_ellipsisFound"/> --> |
| 51 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_powFound"/> --> |
| 52 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_pow_equalFound"/> --> |
| 53 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_spaceshipFound"/> --> |
| 54 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/> --> |
| 55 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/> --> |
| 56 |
<!-- <exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/> --> |
| 57 |
<!-- </rule> --> |
| 58 |
|
| 59 |
<!-- |
| 60 |
############################################################################# |
| 61 |
Handbook: PHP - Formatting SQL statements. |
| 62 |
Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#formatting-sql-statements |
| 63 |
############################################################################# |
| 64 |
--> |
| 65 |
|
| 66 |
<!-- Rule: in $wpdb->prepare - %s is used for string placeholders and %d is used for integer |
| 67 |
placeholders. Note that they are not 'quoted'! --> |
| 68 |
<rule ref="WordPress.DB.PreparedSQLPlaceholders"/> |
| 69 |
<!-- <rule ref="WordPress.DB.DirectDatabaseQuery" /> --> |
| 70 |
|
| 71 |
<!-- Covers rule: $wpdb->prepare()... The benefit of this is that we don't have to remember |
| 72 |
to manually use esc_sql(), and also that it is easy to see at a glance whether something |
| 73 |
has been escaped or not, because it happens right when the query happens. --> |
| 74 |
<rule ref="WordPress.DB.PreparedSQL"/> |
| 75 |
|
| 76 |
<!-- Covers rule: Avoid touching the database directly. --> |
| 77 |
<rule ref="WordPress.DB.RestrictedFunctions"/> |
| 78 |
<rule ref="WordPress.DB.RestrictedClasses"/> |
| 79 |
|
| 80 |
</ruleset> |