Skip to content

Upgrade WPCS to 3.4.1 and PHPCS to 3.13 - #79

Merged
joehoyle merged 5 commits into
WP-API:mainfrom
humanmade:deps/upgrade-wpcs
Sep 1, 2026
Merged

Upgrade WPCS to 3.4.1 and PHPCS to 3.13#79
joehoyle merged 5 commits into
WP-API:mainfrom
humanmade:deps/upgrade-wpcs

Conversation

@roborourke

Copy link
Copy Markdown
Contributor

Summary

Upgrades the dev toolchain to clear a Composer security advisory that currently blocks every CI job on this repo.

Changes

  • wp-coding-standards/wpcs: ^2.1.1^3.4.1 (fixes CVE-2026-45293 — arbitrary code execution via eval() in the WordPress.WP.EnqueuedResourceParameters sniff, High / CVSS 8.6)
  • squizlabs/php_codesniffer: ^3.3.1^3.13.1 (required by WPCS 3)
  • yoast/phpunit-polyfills: ^1.1 || ^2.0^2.0
  • Drop PHP 7.4 from the CI matrix (WPCS 3.4 requires PHP >= 8.0)
  • Update .phpcs.xml.dist for WPCS 3 (short-array sniff moved GenericUniversal)
  • Fix sniffs surfaced by WPCS 3: elseif in class-base.php, __DIR__ in admin/namespace.php, class closing brace in class-implicit.php
  • Remove the installed_paths override that broke PHPCS 3.x sniff discovery
  • Fix the two PHPCS warnings WPCS 3 exposed (unused `` param, reserved $default param name)
  • Keep composer.lock gitignored (plugin project; lockfiles not committed)
  • Bump actions/checkout and actions/cache to Node 24 releases

Validation

  • vendor/bin/phpcs: clean (0 errors)
  • PHPUnit: 100 tests, 240 assertions OK (WP 7.0 / PHP 8.3)
  • CI matrix (PHP 8.0–8.3 × WP 6.5–6.9, single + multisite): green

@joehoyle could you take a look?

roborourke and others added 5 commits September 1, 2026 14:26
WPCS 2.x is affected by CVE-2026-45293 (arbitrary code execution via
eval() in the EnqueuedResourceParameters sniff). Upgrade to the fixed
3.4.1 release, which requires PHPCS >= 3.13 and PHP >= 8.0, so drop
PHP 7.4 from the CI matrix.

WPCS 3 moves the short-array sniff from Generic to Universal, so update
the ruleset exclusion, and fix the new sniff violations surfaced by the
upgraded standard (elseif, __DIR__, class closing brace).

Composer lockfiles are not committed for composer/installers plugin
projects; composer.lock stays gitignored.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
WPCS 3.4.1 pulls in phpcsstandards/phpcsextra and phpcsstandards/phpcsutils
as dependencies for its Universal, NormalizedArrays, Modernize, and
PHPCSUtils sniffs. The post-install-cmd/post-update-cmd scripts hardcoded
PHPCS's installed_paths to only vendor/wp-coding-standards/wpcs, which
overwrote the paths that dealerdirect/phpcodesniffer-composer-installer
already auto-configures for every installed standard, so those sniffs
could not be found and phpcs exited with code 3 in CI.

Removing the scripts lets the installer plugin's auto-configuration take
over, which includes all installed standards' paths.
WPCS 3.4.1 adds the Universal.NamingConventions.NoReservedKeywordParameterNames
sniff, which flags $default in Access_Token::get_meta() since `default` is a
reserved keyword. Renamed to $default_value.

Also removed the unused $args parameter from Authorization_Code::validate() —
Generic.CodeAnalysis.UnusedFunctionParameter flagged it, and grepping the
codebase confirms no interface or caller relies on it.

phpcs now exits 0 instead of 1, which was failing CI even though these were
only warnings, not errors.
GitHub Actions runners now log a deprecation warning on every job because
actions/checkout@v4 and actions/cache@v4 still target Node 20, which
GitHub is retiring. Bumping to actions/checkout@v7 and actions/cache@v6
(both node24) removes the warning; no config changes were needed for
either action.
Upgrade WPCS to 3.4.1 and PHPCS to 3.13
@roborourke

roborourke commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@joehoyle initial bit of maintenance it'd be good to land before the PKCE stuff as it'll ship a load more tests and ideally we can just require more recent PHP versions and latest PHPUnit etc...

@joehoyle
joehoyle merged commit 527c8be into WP-API:main Sep 1, 2026
21 checks passed
@roborourke
roborourke deleted the deps/upgrade-wpcs branch September 2, 2026 09:15
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