Fixes the 17 errors and 17 warnings surfaced by the WPCS 3.x upgrade,
verified clean with tests/vendor/bin/phpcs (0 errors, 0 warnings, 237
files) and tests/vendor/bin/phpcs --standard=.phpcs-security.xml
(0 violations, 192 files) in a PHP 7.4 Docker container.
- Universal.Namespaces.DisallowCurlyBraceSyntax: converted
tests/helpers.php, src/lib/helper.php and src/addons/addons.php from
brace to semicolon namespace syntax.
- PSR12.Files.FileHeader: moved the docblock above the namespace
statement in tests/bootstrap.php, and merged the split use-statement
groups in Support_Page.php (class uses, then function uses).
- Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence: added
clarifying parentheses around mixed &&/|| expressions in
general-page.php (cb_frame and uc_frame) and dashboard-page.php,
same logic.
- Universal.NamingConventions.NoReservedKeywordParameterNames: renamed
reserved-keyword parameters ($default -> $default_format/
$default_value, $class -> $class_name) in Cookiebot_CLI_Command,
Settings_Service(_Interface) and helper.php; all call sites use
positional args so this is safe.
- Generic.CodeAnalysis.UnusedFunctionParameter: dropped the genuinely
unused $assoc_args/$args from two WP-CLI command methods; suppressed
the false positive on Base_Cookiebot_Addon::get_instance(), whose
params are intentionally forwarded via func_get_args().
- Universal.Files.SeparateFunctionsFromOO: split the deprecated
Cookiebot_WP class out of global-deprecations.php into its own
global-deprecations-class.php (functions-only file left behind),
required from cookiebot.php.
- WordPress.WP.Capabilities.Unknown: declared network_settings_page as
a custom_capabilities entry in .phpcs.xml since it isn't a WordPress
core capability (no behavior change).
Summary
Upgrades
wp-coding-standards/wpcs2.3.0 to 3.4.1 to clear CVE-2026-45293. There is no 2.xbackport, so the 3.x major upgrade is required.
JIRA: CMS-3069 (details and impact assessment there)
What changed
tests/composer.json: wpcs"*"to"^3.4.1"tests/composer.lock: wpcs 3.4.1, php_codesniffer 3.13.6 (required by wpcs), plus new depsphpcsstandards/phpcsutilsandphpcsstandards/phpcsextra.phpcs.xmland.phpcs-security.xml: three required migrations for WPCS 3.x, see belowRuleset migration, why each change is needed
installed_pathsgainsphpcsutilsandphpcsextra. WPCS 3 depends on both. Thecomposer-installer normally auto-registers them, but these rulesets set
installed_pathsexplicitly, which overrides that. Without this, phpcs errors with "referenced sniff not found".
WordPress.WhiteSpace.PrecisionAlignment.Foundrenamed toUniversal.WhiteSpace.PrecisionAlignment.Found.The sniff moved to PHPCSExtra in WPCS 3.0. The old exclude silently stops matching.
blank_line_checkproperty removed. It was dropped in WPCS 3.0 and now causes phpcs toerror on an unknown property.
Checked against WPCS 3.4.1 and deliberately left alone: the
YodaConditions.NotYodaexclude andboth
WordPress.Files.FileName.*excludes are still valid.dealerdirect/phpcodesniffer-composer-installerstays at^0.7, tested as working with WPCS 3.4.1.Draft: 34 lint violations still to fix
Baseline on master is 0 violations. This upgrade surfaces 34 new ones (17 errors, 17 warnings)
across 14 files, from sniffs added in WPCS 3.x / PHPCSExtra.
phpcbfauto-fixes none of them.Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence.MissingParenthesesGeneric.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsedUniversal.NamingConventions.NoReservedKeywordParameterNames.defaultFoundUniversal.Namespaces.DisallowCurlyBraceSyntax.ForbiddenUniversal.NamingConventions.NoReservedKeywordParameterNames.classFoundWordPress.WP.Capabilities.UnknownPSR12.Files.FileHeader.IncorrectGroupingPSR12.Files.FileHeader.IncorrectOrderUniversal.Files.SeparateFunctionsFromOO.MixedPlease do not resolve these by weakening
.phpcs-security.xml. That ruleset reports 0 violationsboth before and after the upgrade.
Test plan
Universal.*sniffs, no "referenced sniff not found".phpcs-security.xmlclean (191 files, 0 violations)PHP 7.4 Lintgreen