mirror of
https://gh.wpcy.net/https://github.com/WordPress/WordPress-Coding-Standards.git
synced 2026-04-26 00:02:20 +08:00
Long anticipated, finally here: PHPCompatibility 10.0.0-alpha1 🎉 PHPCompatibility 10.0.0 brings huge improvements in both what is being detected (> 50 new sniffs), as well as the detection accuracy for pre-existing sniffs. Even though still "unstable", it is stable enough for our purposes and the advantages of using it outweigh the disadvantage of it being an unstable version. By setting the `minimum-stability` and `prefer-stable` settings in the `composer.json`, we can ensure that we don't get the `dev-develop` branch, but rather get a `10.0.0` tag, unstable or not. And what with the improved detection, a number of new PHP token constants previously not flagged, are now flagged, so let's ignore them as PHPCS polyfills these. Ref: * https://github.com/PHPCompatibility/PHPCompatibility/wiki/Upgrading-to-PHPCompatibility-10.0 * https://github.com/PHPCompatibility/PHPCompatibility/releases/tag/10.0.0-alpha1
103 lines
4.3 KiB
XML
103 lines
4.3 KiB
XML
<?xml version="1.0"?>
|
|
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://schema.phpcodesniffer.com/phpcs.xsd">
|
|
|
|
<description>The Coding standard for the WordPress Coding Standards itself.</description>
|
|
|
|
<!--
|
|
#############################################################################
|
|
COMMAND LINE ARGUMENTS
|
|
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
|
|
#############################################################################
|
|
-->
|
|
|
|
<file>.</file>
|
|
|
|
<!-- Exclude Composer vendor directory. -->
|
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
|
|
|
<!-- Only check PHP files. -->
|
|
<arg name="extensions" value="php"/>
|
|
|
|
<!-- Show progress, show the error codes for each message (source). -->
|
|
<arg value="ps"/>
|
|
|
|
<!-- Strip the filepaths down to the relevant bit. -->
|
|
<arg name="basepath" value="."/>
|
|
|
|
<!-- Check up to 8 files simultaneously. -->
|
|
<arg name="parallel" value="8"/>
|
|
|
|
|
|
<!--
|
|
#############################################################################
|
|
SET UP THE RULESETS
|
|
#############################################################################
|
|
-->
|
|
|
|
<rule ref="WordPress">
|
|
<!-- This project needs to comply with naming standards from PHPCS, not WP. -->
|
|
<exclude name="WordPress.Files.FileName"/>
|
|
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
|
|
|
|
<!-- While conditions with assignments are a typical way to walk the token stream. -->
|
|
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
|
|
|
|
<!-- The code in this project is run in the context of PHPCS, not WP. -->
|
|
<exclude name="WordPress.DateTime"/>
|
|
<exclude name="WordPress.DB"/>
|
|
<exclude name="WordPress.Security"/>
|
|
<exclude name="WordPress.WP"/>
|
|
|
|
<!-- Linting is done in a separate CI job, no need to duplicate it. -->
|
|
<exclude name="Generic.PHP.Syntax"/>
|
|
</rule>
|
|
|
|
<!-- Check code for cross-version PHP compatibility. -->
|
|
<config name="testVersion" value="7.2-"/>
|
|
<rule ref="PHPCompatibility">
|
|
<!-- Exclude PHP constants back-filled by PHPCS. -->
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_bad_characterFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_fnFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_attributeFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_matchFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_nullsafe_object_operatorFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_name_fully_qualifiedFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_name_qualifiedFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_name_relativeFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_readonlyFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_enumFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_public_setFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_protected_setFound"/>
|
|
<exclude name="PHPCompatibility.Constants.NewConstants.t_private_setFound"/>
|
|
<exclude name="PHPCompatibility.Constants.RemovedConstants.t_bad_characterFound"/>
|
|
</rule>
|
|
|
|
<!-- Enforce PSR1 compatible namespaces. -->
|
|
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
|
|
|
<!-- Enforce that classes are abstract or final. -->
|
|
<rule ref="Universal.Classes.RequireFinalClass">
|
|
<!-- ... with the exception of four sniffs which are known to be extended by external standards. -->
|
|
<exclude-pattern>/WordPress/Sniffs/NamingConventions/ValidHookNameSniff\.php$</exclude-pattern>
|
|
<exclude-pattern>/WordPress/Sniffs/Security/(EscapeOutput|NonceVerification|ValidatedSanitizedInput)Sniff\.php$</exclude-pattern>
|
|
</rule>
|
|
|
|
<!-- Enforce that methods in traits are always final. -->
|
|
<rule ref="Universal.FunctionDeclarations.RequireFinalMethodsInTraits"/>
|
|
|
|
|
|
<!--
|
|
#############################################################################
|
|
SNIFF SPECIFIC CONFIGURATION
|
|
#############################################################################
|
|
-->
|
|
|
|
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
|
|
<properties>
|
|
<property name="alignMultilineItems" value="!=100"/>
|
|
<property name="exact" value="false" phpcs-only="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
</ruleset>
|