| 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.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved"> |
|---|
| 80 | <exclude-pattern>/ID3/getid3\.php$</exclude-pattern> |
|---|
| 81 | </rule> |
|---|
| 82 | <rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated"> |
|---|
| 83 | <exclude-pattern>/ID3/getid3\.php$</exclude-pattern> |
|---|
| 84 | <exclude-pattern>/PHPMailer/PHPMailer\.php$</exclude-pattern> |
|---|
| 85 | </rule> |
|---|
| 86 | <rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated"> |
|---|
| 87 | <exclude-pattern>/ID3/getid3\.php$</exclude-pattern> |
|---|
| 88 | </rule> |
|---|
| 89 | <rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated"> |
|---|
| 90 | <exclude-pattern>/ID3/getid3\.php$</exclude-pattern> |
|---|
| 91 | </rule> |
|---|
| 92 | <rule ref="PHPCompatibility.Lists.AssignmentOrder.Affected"> |
|---|
| 93 | <exclude-pattern>/ID3/module.audio-video.quicktime\.php$</exclude-pattern> |
|---|
| 94 | </rule> |
|---|
| 95 | <rule ref="PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated"> |
|---|
| 96 | <exclude-pattern>/PHPMailer/PHPMailer\.php$</exclude-pattern> |
|---|
| 97 | </rule> |
|---|
| 98 | <rule ref="PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet"> |
|---|
| 99 | <exclude-pattern>/PHPMailer/PHPMailer\.php$</exclude-pattern> |
|---|
| 100 | </rule> |
|---|
| 101 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_sign_keypair_from_secretkey_and_publickeyFound"> |
|---|
| 102 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 103 | </rule> |
|---|
| 104 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_padFound"> |
|---|
| 105 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 106 | </rule> |
|---|
| 107 | <rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_unpadFound"> |
|---|
| 108 | <exclude-pattern>/sodium_compat/src/Compat\.php$</exclude-pattern> |
|---|
| 109 | </rule> |
|---|
| 110 | <rule ref="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__serializeFound"> |
|---|
| 111 | <exclude-pattern>/sodium_compat/src/PHP52/SplFixedArray\.php$</exclude-pattern> |
|---|
| 112 | </rule> |
|---|
| 113 | <rule ref="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound"> |
|---|
| 114 | <exclude-pattern>/sodium_compat/src/PHP52/SplFixedArray\.php$</exclude-pattern> |
|---|
| 115 | </rule> |
|---|
| 116 | |
|---|
| 117 | <!-- |
|---|
| 118 | Excluded while waiting for PHPCompatibility v10. |
|---|
| 119 | See <https://github.com/PHPCompatibility/PHPCompatibility/issues/1481>. |
|---|
| 120 | --> |
|---|
| 121 | <rule ref="PHPCompatibility.FunctionDeclarations.NewClosure.ThisFoundInStatic"> |
|---|
| 122 | <exclude-pattern>/src/wp-includes/script-loader\.php$</exclude-pattern> |
|---|
| 123 | </rule> |
|---|
| 124 | |
|---|
| 125 | </ruleset> |
|---|