Make WordPress Core

Changeset 56695 for trunk/composer.json

09/26/2023 12:24:43 AM (7 months ago)

Coding Standards: Upgrade WPCS to version 3.0.0.

This is an important release which makes significant changes to improve the accuracy, performance, stability and maintainability of all sniffs, as well as making WordPressCS much better at handling modern PHP.

WordPressCS 3.0.0 contains breaking changes, both for people using ignore annotations, people maintaining custom rulesets, as well as for sniff developers who maintain a custom PHPCS standard based on WordPressCS.

If you are an end-user or maintain a custom WordPressCS based ruleset, please start by reading the Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers which lists the most important changes and contains a step by step guide for upgrading.

If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WordPressCS sniffs, please read the Upgrade Guide to WordPressCS 3.0.0 for Developers.

In all cases, please read the complete changelog carefully before you upgrade.

This commit:

  • Updates the Composer dependencies to use the new version, including updating the underlying PHP_CodeSniffer dependency to the new minimum supported version for WPCS.
    Note: the Composer PHPCS installer plugin is no longer explicitly required as it is now a dependency of WPCS, so the dependency is inherited automatically.
  • Updates the ruleset for WPCS 3.0.0. This includes:
    • Raising the memory limit to be on the safe side as WPCS 3.0.0 contains a lot more sniffs.
    • Removing explicit inclusions of extra rules, which have now been added to the WordPress-Core ruleset..
    • Updating property names for select sniffs.
    • Updating one exclusion — the WordPress.CodeAnalysis.AssignmentInCondition sniff has been (partially) replaced by the Generic.CodeAnalysis.AssignmentInCondition sniff.
    • Adding one new exclusion.
  • Downgrades one new error to a warning.
    The Generic.Files.OneObjectStructurePerFile sniff enforces that there is only one OO structure declaration per file. At this time, this sniff would yield 29 errors. By downgrading the sniff to a warning, the build can pass and the issues can be fixed in due time. For now, the test directory will be excluded until the issues are fixed (as the test directory CS run does not allow for warnings).
  • Updates ignore annotations for WPCS 3.0.0.

Reference: WPCS 3.0.0 release notes.

Follow-up to [43571], [44574], [45600], [47927].

Props jrf, jorbin, desrosj.
See #59161.

1 edited


  • trunk/composer.json

    r56687 r56695  
    1717    },
    1818    "require-dev": {
    19         "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
    20         "squizlabs/php_codesniffer": "3.6.0",
    21         "wp-coding-standards/wpcs": "~2.3.0",
     19        "squizlabs/php_codesniffer": "3.7.2",
     20        "wp-coding-standards/wpcs": "~3.0.0",
    2221        "phpcompatibility/phpcompatibility-wp": "~2.1.3",
    2322        "yoast/phpunit-polyfills": "^1.1.0"
Note: See TracChangeset for help on using the changeset viewer.