Skip to content

Fix PHPCS deprecation warnings and update obsolete ruleset directives - #653

Merged
eason9487 merged 3 commits into
trunkfrom
dev/update-phpcs-ruleset
Aug 24, 2026
Merged

Fix PHPCS deprecation warnings and update obsolete ruleset directives#653
eason9487 merged 3 commits into
trunkfrom
dev/update-phpcs-ruleset

Conversation

@eason9487

Copy link
Copy Markdown
Member

Changes proposed in this Pull Request:

This issue was discovered while bumping the supported versions of WordPress.

./vendor/bin/phpcs printed a DEPRECATED notice and a WARNING before every scan. Fixing those surfaced two more directives in phpcs.xml.dist that had silently stopped doing anything, so this PR also brings the ruleset back in line with what WPCS 3.x provides.

  1. Fix deprecated syntax. text_domain now uses <element> nodes, and <rule ref="Squiz.Classes"> is replaced by a direct reference to the one sniff in that category the ruleset actually needs. The category reference was dragging in DuplicateProperty, a JavaScript-only sniff deprecated in PHPCS 3.9.0, which produced the WARNING. Excluding that sniff by name would also have silenced it, but an exclude naming a sniff that does not exist aborts PHPCS with exit code 3, so it would break the moment PHPCS 4.0 removes it.
  2. Update renamed and obsolete directives. WPCS 3.0.0 renamed minimum_supported_wp_version to minimum_wp_version and silently ignores the old name, so the deprecation sniffs have been comparing against the WPCS default of 6.7 rather than the 7.0 this plugin declares. Also drops the exclusion for Squiz.Commenting.LongConditionClosingComment, which WPCS removed from WordPress-Core back in 0.12.0.
  3. Drop redundant references. Six sniffs listed under "Include some other sniffs we want to enforce" have since been added to the WordPress standard, so referencing them again enforces nothing.

Worth knowing when reviewing: item 2 changes lint strictness, not just syntax. Findings for APIs deprecated between 6.7 and 7.0 now surface as errors rather than warnings. Nothing in the plugin triggers that today, so the scan is clean either way, but a future WPCS bump could surface as an error what would previously have been a warning. That is the intended behavior.

Checks:

  • Does your code follow the WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Detailed test instructions:

  1. On trunk, run ./vendor/bin/phpcs and note the DEPRECATED notice about text_domain and the WARNING about Squiz.Classes.DuplicateProperty.
  2. Check out this branch and run ./vendor/bin/phpcs again.
  3. Confirm both messages are gone and the scan still reports no violations.

Changelog entry

Pass the I18n text_domain through <element> nodes instead of a
comma-separated string, deprecated since PHP_CodeSniffer 3.3.0.

Reference Squiz.Classes.ClassDeclaration directly instead of the whole
Squiz.Classes category. The category also pulled in DuplicateProperty, a
JS-only sniff deprecated in PHPCS 3.9.0 that PHPCS warns about on every
run. Of the rest, ClassFileName had its only code excluded already, and
ValidClassName had NotCamelCaps excluded and reports MissingBrace only
on a class with no opening brace, which Generic.PHP.Syntax already
reports as a parse error. The WordPress standard covers the last two:
Generic.PHP.LowerCaseKeyword supersedes LowercaseClassKeywords, and
SelfMemberReference is enabled there.
WPCS 3.0.0 renamed the minimum_supported_wp_version config to
minimum_wp_version. The old name is silently ignored, so the deprecation
sniffs have been comparing against the WPCS default of 6.7 instead of the
minimum WP version the plugin declares.

WPCS 0.12.0 removed Squiz.Commenting.LongConditionClosingComment from
WordPress-Core, so excluding it no longer has any effect.
WPCS has since added these six sniffs to the WordPress standard, so
referencing them again enforces nothing and only creates a second place
that can drift from upstream. The sniffs left in this block are the ones
the standard genuinely does not enable.
@eason9487 eason9487 self-assigned this Aug 24, 2026
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • phpcs.xml.dist is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d805413a-e7d8-4acf-94ba-15d5c3878cd1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the changelog: dev Developer-facing only change. label Aug 24, 2026
@eason9487
eason9487 requested a lite review from Copilot August 24, 2026 08:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the PHPCS ruleset for WPCS 3.x compatibility, removing deprecated syntax and obsolete directives.

Changes:

  • Renames the minimum WordPress version setting.
  • Updates deprecated text_domain and Squiz rule syntax.
  • Removes obsolete and redundant sniff references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@eason9487
eason9487 merged commit c0a1cf1 into trunk Aug 24, 2026
6 checks passed
@eason9487
eason9487 deleted the dev/update-phpcs-ruleset branch August 24, 2026 08:34
@eason9487 eason9487 mentioned this pull request Aug 25, 2026
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: dev Developer-facing only change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants