Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PHPCS #164

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Upgrade PHPCS #164

merged 4 commits into from
Oct 16, 2024

Conversation

matt-bernhardt
Copy link
Member

@matt-bernhardt matt-bernhardt commented Oct 16, 2024

The key change here is upgrading the version of the WordPress coding standards that we apply to the application. A lot changed when these standards hit the 3.x release, including support for PHP 8.x - so gettting everything in place caused follow-on changes to a handful of files.

As a side effect of this work, I've added PHP 8.3 to our list of tested language versions. It isn't clear to me yet whether we'll upgrade straight to 8.3 or not, but since it's ready we might as well check with it. When PHP 8.4 is out, we'll add that too.

To confirm these changes:

  • run composer install to get the new tooling in place locally
  • run composer security, which should produce no errors
  • run composer lint, which should take a few minutes and flag a fair number of known issues (sadly). The key outcome is that you see flagged code, not a failure of the tool to run.

While the changes here won't affect how WordPress runs, I've set up a multidev on this branch to confirm that none of these changes will impact Pantheon's build workflow. You can confirm this multidev exists in the Pantheon dashboard (I don't like to link to multidevs since these pages get crawled)

Credit to @JPrevost for writing the original documentation page I'm including here. I tweaked the wording a bit and added some links, but he wrote this a year or so ago in a branch that never ended up merging.

Developer

Stylesheets

  • Any theme or plugin whose stylesheets have changed has had its version
    string incremented.
  • No version change is needed

Secrets

  • All new secrets have been added to Pantheon tiers
  • Relevant secrets have been updated in Github Actions
  • All new secrets documented in README
  • No secrets are affected by this work

Documentation

  • Project documentation has been updated
  • No documentation changes are needed

Accessibility

  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • There are no a11y implications to this work

Stakeholder approval

  • Stakeholder approval has been confirmed
  • Stakeholder approval is not needed

Dependencies

YES dependencies are updated (see composer.json and composer.lock)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • The changes have been verified
  • The documentation has been updated or is unnecessary
  • New dependencies are appropriate or there were no changes

@matt-bernhardt matt-bernhardt force-pushed the fix-phpcs branch 2 times, most recently from a0fc61e to 50f0451 Compare October 16, 2024 01:21
** Why are these changes being introduced:

* We are currently using WPCS release 2.3, but the latest version is now
  3.x. A number of supporting packages are implicated in this upgrade.

** Relevant ticket(s):

n/a (maintenance work)

** How does this address that need:

This upgrades our version of the WP coding standards to the latest
release, and rebuilds the tooling and integration:

* Changes the PHPCS application itself to be a plugin in this repo,
  rather than a dev dependency package (per their documentation).

* Renames the `composer test` script to be `composer lint`, which is
  more in line with what this tool does.

* Updates the phpcs.security.xml scoping configuration, removing a
  reference to the deprecated WordPress.Classes family of checks, and
  adding some new Modernize and Universal checks to the removal list.
  The purpose of this security configuration is to run _only_ the
  security checks, requiring no failures in order for a PR to merge.
  General-purpose linting, using all checks, still happens using the
  more generic phpcs.xml configuration as part of `composer lint`.

** Document any side effects to this change:

* None
We are using PHP 8.1, but run CI on future versions of PHP as a way
of protecting our upgrade pathway. In this sense, it makes sense to
check all future versions of PHP, not just the next version.
The contents were already ignored, but removes the directory itself.
Copy link

@djanelle-mit djanelle-mit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work looks good to me!

I was able to replicate the desired output of composer lint on my local environment, and the multidev for this branch works as I'd expect. I can't think of other places for this particular example that I'd be concerned about (with my limited experience).

Should be good to merge.

@matt-bernhardt matt-bernhardt merged commit cf3e777 into master Oct 16, 2024
4 checks passed
@matt-bernhardt matt-bernhardt deleted the fix-phpcs branch October 16, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants