| 1 | <?xml version="1.0"?> |
|---|
| 2 | <ruleset name="WordPress PHP Compatibility"> |
|---|
| 3 | <description>Apply PHP compatibility checks to all WordPress Core files</description> |
|---|
| 4 | |
|---|
| 5 | <!-- |
|---|
| 6 | ############################################################################# |
|---|
| 7 | COMMAND LINE ARGUMENTS |
|---|
| 8 | https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset |
|---|
| 9 | ############################################################################# |
|---|
| 10 | --> |
|---|
| 11 | |
|---|
| 12 | <!-- Only scan PHP files. --> |
|---|
| 13 | <arg name="extensions" value="php"/> |
|---|
| 14 | |
|---|
| 15 | <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. --> |
|---|
| 16 | <arg name="cache" value=".cache/phpcompat.json"/> |
|---|
| 17 | |
|---|
| 18 | <!-- Set the memory limit to 256M. |
|---|
| 19 | For most standard PHP configurations, this means the memory limit will temporarily be raised. |
|---|
| 20 | Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-phpini-settings |
|---|
| 21 | --> |
|---|
| 22 | <ini name="memory_limit" value="256M"/> |
|---|
| 23 | |
|---|
| 24 | <!-- Strip the filepaths down to the relevant bit. --> |
|---|
| 25 | <arg name="basepath" value="./"/> |
|---|
| 26 | |
|---|
| 27 | <!-- Check up to 20 files simultaneously. --> |
|---|
| 28 | <arg name="parallel" value="20"/> |
|---|
| 29 | |
|---|
| 30 | <!-- Show sniff codes in all reports. --> |
|---|
| 31 | <arg value="ps"/> |
|---|
| 32 | |
|---|
| 33 | <!-- |
|---|
| 34 | ############################################################################# |
|---|
| 35 | FILE SELECTION |
|---|
| 36 | Set which files will be subject to the scans executed using this ruleset. |
|---|
| 37 | ############################################################################# |
|---|
| 38 | --> |
|---|
| 39 | |
|---|
| 40 | <!-- For now, only the files in src are scanned. --> |
|---|
| 41 | <file>./src/</file> |
|---|
| 42 | |
|---|
| 43 | <!-- Exclude Must-Use plugins. --> |
|---|
| 44 | <exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern> |
|---|
| 45 | |
|---|
| 46 | <!-- Exclude plugins. --> |
|---|
| 47 | <exclude-pattern>/src/wp-content/plugins/*</exclude-pattern> |
|---|
| 48 | |
|---|
| 49 | <!-- Exclude themes except the twenty* themes. --> |
|---|
| 50 | <exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern> |
|---|
| 51 | |
|---|
| 52 | <!-- Exclude translation files. --> |
|---|
| 53 | <exclude-pattern>/src/wp-content/languages/*</exclude-pattern> |
|---|
| 54 | |
|---|
| 55 | <!-- |
|---|
| 56 | PHPCompatibilityParagonieSodiumCompat prevents false positives in `sodium_compat`. |
|---|
| 57 | However, because these files are included in a non-standard path, false positives are triggered in WordPress Core. |
|---|
| 58 | --> |
|---|
| 59 | <exclude-pattern>src/wp-includes/sodium_compat/lib/php72compat_const\.php$</exclude-pattern> |
|---|
| 60 | |
|---|
| 61 | <!-- |
|---|
| 62 | ############################################################################# |
|---|
| 63 | SET UP THE RULESET |
|---|
| 64 | ############################################################################# |
|---|
| 65 | --> |
|---|
| 66 | |
|---|
| 67 | <rule ref="PHPCompatibilityWP"/> |
|---|
| 68 | |
|---|
| 69 | <!-- WordPress Core currently supports PHP 7.2+. --> |
|---|
| 70 | <config name="testVersion" value="7.2-"/> |
|---|
| 71 | |
|---|
| 72 | <!-- |
|---|
| 73 | ############################################################################# |
|---|
| 74 | SELECTIVE EXCLUSIONS |
|---|
| 75 | Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs. |
|---|
| 76 | ############################################################################# |
|---|
| 77 | --> |
|---|
| 78 | |
|---|
| 79 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_keypair_from_secretkey_and_publickeyFound"> |
|---|
| 80 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 81 | </rule> |
|---|
| 82 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_padFound"> |
|---|
| 83 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 84 | </rule> |
|---|
| 85 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_unpadFound"> |
|---|
| 86 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 87 | </rule> |
|---|
| 88 | |
|---|
| 89 | </ruleset> |
|---|