Fix PHPCS deprecation warnings and update obsolete ruleset directives - #653
Conversation
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.
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
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_domainand 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.
Changes proposed in this Pull Request:
This issue was discovered while bumping the supported versions of WordPress.
./vendor/bin/phpcsprinted a DEPRECATED notice and a WARNING before every scan. Fixing those surfaced two more directives inphpcs.xml.distthat had silently stopped doing anything, so this PR also brings the ruleset back in line with what WPCS 3.x provides.text_domainnow 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 inDuplicateProperty, 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.minimum_supported_wp_versiontominimum_wp_versionand 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 forSquiz.Commenting.LongConditionClosingComment, which WPCS removed fromWordPress-Coreback in 0.12.0.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:
Detailed test instructions:
trunk, run./vendor/bin/phpcsand note the DEPRECATED notice abouttext_domainand the WARNING aboutSquiz.Classes.DuplicateProperty../vendor/bin/phpcsagain.Changelog entry