site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Upgrade PHPCS standards

Open aaemnnosttv opened this issue 1 year ago • 2 comments

Feature Description

In order to support compatibility with newer versions of PHP, we need to upgrade some of our tooling for compatibility, such as PHPCS.

WPCS recently released a long-awaited major release (v3) which adds needed compatibility with PHP 8.

Similarly, the WP VIP coding standards automattic/vipwpcs also released a new matching major version.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • wp-coding-standards/wpcs and automattic/vipwpcs should be upgraded to their latest versions
  • The PHPCS configuration should be updated as necessary to preserve compatibility with our current rules
  • Simple fixes that can be applied automatically by PHPCS should be included
    • anything requiring substantial manual updating/review should be excluded temporarily and a follow-up issue opened to address

Implementation Brief

  • Update wp-coding-standards/wpcs and automattic/vipwpcs to ^3 in composer.json and upgrade these with Composer to install the latest (including their dependencies)
  • This issue is largely about applying automatic fixes working through the failures raised and updating configuration as necessary
    • E.g. The WP core rule WordPress.PHP.DisallowShortTernary no longer exists and has been replaced by the Universal.Operators.DisallowShortTernary rule, so some reworking of the PHPCS configuration file is needed. This isn't very intuitive and can result in many more errors raised if done incorrectly.

Test Coverage

  • No changes in coverage

QA Brief

No QA needed as this is purely a code style/formatting change.

Changelog entry

  • N/A

aaemnnosttv avatar May 16 '24 20:05 aaemnnosttv

@aaemnnosttv I hope https://github.com/google/site-kit-wp/pull/8757 is helpful. I haven't addressed any errors aside from updating the obsolete sniff names. Please feel free to decide which sniffs you want to run on this code (report summary added in the PR description), and I can take care of the remaining fixes.

thelovekesh avatar May 25 '24 15:05 thelovekesh

IB ✔️

eugene-manuilov avatar Jun 27 '24 16:06 eugene-manuilov

Moving directly to Approval since no QA is needed for this one 🙂

tofumatt avatar Jul 09 '24 08:07 tofumatt