This release raises the minimum requirements and reworks a large number of the VIPCS sniffs.
The minimum WordPressCS requirement is raised to 3.4.1 (from 3.2.0) — a security release which also brings numerous accuracy improvements to sniffs that VIPCS bundles — along with PHP_CodeSniffer 3.13.5, PHPCSUtils 1.2.3, PHPCSExtra 1.5.1 and VariableAnalysis 2.13.0. The minimum PHP version is now 7.4. Many sniffs have been reworked to fix false positives, add support for modern PHP syntaxes and adopt PHPCSUtils. The JavaScript-specific sniffs and the DynamicCalls sniff have been hard-deprecated ahead of their removal in 4.0.0, and the unused Security.Twig sniff has been removed.
Please ensure you run composer update automattic/vipwpcs --with-dependencies to benefit from this.
Added
- #882: Performance/NoPaging: flag
posts_per_pageandnumberpostsset to-1(WordPress' "no limit" value), which previously slipped past the WPCS> 100check. - #883: Hooks/AlwaysReturnInFilter:
exit,dieorthrowin a filter callback now raises a dedicatedTerminatingInsteadOfReturnwarning, instead of the genericMissingReturnStatementerror. - #890: Add a Byte Order Mark (BOM) check to the
WordPressVIPMinimumruleset.
Changed
- #824: Disable
WordPress.Security.EscapeOutput.ExceptionNotEscapedin theWordPressVIPMinimumruleset, as throwing an exception with a translated message triggered it and the check is considered controversial. - #854: Functions/StripTags: always flag use of
strip_tags(), as the function should never be used on the VIP platform. - As VIPCS bundles a number of WordPressCS sniffs and the minimum WordPressCS version has been raised to 3.4.1, users will now receive more accurate results from the following WPCS sniffs (see the WordPressCS 3.3.0, 3.4.0 and 3.4.1 release notes for full details):
WordPress.DB.DirectDatabaseQuery: recognises more caching functions (such as thewp_cache_*_multiple()andwp_cache_*_salted()functions), and has fewer false positives when caching functions are called using a non-canonical function name.WordPress.DB.PreparedSQL: fewer false positives for correctly escaped SQL called using a non-canonical function name, and for static method calls to a non-global class namedwpdb.WordPress.Security.EscapeOutput: adds support for attributes on anonymous classes (PHP 8.0),readonlyanonymous classes (PHP 8.3) andexitas a function call (PHP 8.4); expands*::classfalse-positive protection; fixes false positives/negatives forget_search_query()and_deprecated_file()used with non-standard casing; and no longer treatswp_kses_allowed_html()as an escaping function, which may surface a new warning where that function's return value was being output directly.WordPress.Security.NonceVerification: fewer false positives when the nonce-checking function is called using a non-canonical function name.WordPress.Security.ValidatedSanitizedInput: clearer error message for theInputNotValidatederror code.WordPress.WP.AlternativeFunctions: fixes a false negative when class members share a name with select global WP functions/constants, and a false positive for the fully qualified stream constants\STDIN,\STDOUTand\STDERR.WordPress.WP.CronInterval: fixes a false positive when the callback reference used a different case to the function declaration.
Deprecated
- #839: Hard-deprecate all JavaScript-specific sniffs (
WordPressVIPMinimum.JS.*). They are excluded from the rulesets and will be removed in VIPCS 4.0.0. - #865: Hard-deprecate the
WordPressVIPMinimum.Functions.DynamicCallssniff. It is excluded from the rulesets and will be removed in VIPCS 4.0.0.
Removed
- #864: Remove the unused
WordPressVIPMinimum.Security.Twigsniff.
Fixed
- #840: Fix dangerous comparisons against the value of token constants.
- #842: Security/Mustache: fix potential false positives on a delimiter change, and examine double-quoted strings with interpolation and nowdocs which were previously skipped.
- #846, #848: Security/PHPFilterFunctions: fix false positives for method calls, namespaced function calls and attributes which share the function name.
- #847: Security/StaticStrreplace: fix flawed detection of
str_replace()by extending the WordPressCSAbstractFunctionParameterSniff; method calls, namespaced calls, first-class callables and argument unpacking are no longer flagged. - #850: Variables/ServerVariables: fix incorrect quote stripping and expand safeguards against false positives.
- #851: Constants/ConstantString: fix flawed detection of
define()/defined()by extendingAbstractFunctionParameterSniff, and clarify the error message. - #852: Hooks/RestrictedHooks: fix false positives (method/namespaced calls, first-class callables, attributes) and disregard comments in the hook-name parameter.
- #853: Performance/LowExpiryCacheTime: avoid a possible fatal error when a PHP 7.4+ numeric literal or 8.1+ octal literal is used as the cache time.
- #855: Performance/FetchingRemoteData: fix flawed function-call detection by extending
AbstractFunctionParameterSniff. - #858: Classes/DeclarationCompatibility: modernise and fix the sniff.
- #861: Security/EscapingVoidReturnFunctions: fix flawed detection of
esc_*()/wp_kses*()calls by extendingAbstractFunctionParameterSniff; safeguard argument unpacking, attributes and first-class callables. - #862: Functions/DynamicCalls: fix end-of-statement determination and other minor issues.
- #866: UserExperience/AdminBarRemoval: several fixes — case-insensitive function-name matching, recognise
add_action()as an alias, disregard comments in parameters, and no longer treat a CSS file as PHP; plus PHP 8.0+ function-call and 8.1+ first-class-callable support. - #867: Performance/CacheValueOverride: fix false negatives for fully qualified calls and false positives for PHP 8.1+ first-class callables and variables.
- #869: Constants/RestrictedConstants: fix a nonsensical comparison and use PHPCSUtils for quote stripping.
- #872: Performance/TaxonomyMetaInOptions: extend
AbstractFunctionParameterSniffand add PHP 8.0+ function-call and nullsafe-operator support. - #881: Hooks/AlwaysReturnInFilter: resolve bugs and adopt PHPCSUtils.
Security
- WordPressCS 3.4.1 fixes a vulnerability in the
WordPress.WP.EnqueuedResourceParameterssniff whereby running it over untrusted code could lead to arbitrary command execution on the scanning host. The VIPCS rulesets do not enable that sniff, so VIPCS' own behaviour is unaffected, but raising the minimum WordPressCS version removes the affected releases from the dependency tree and protects users who additionally run theWordPressorWordPress-Extrastandards.
Maintenance
- Composer:
- #857: Raise the minimum supported versions of all coding-standard dependencies. This release requires WordPressCS 3.4.1, PHP_CodeSniffer 3.13.5, PHPCSUtils 1.2.3, PHPCSExtra 1.5.1 and VariableAnalysis 2.13.0.
- #828: Prevent a
composer.lockfile from being created. - #837: Bump the PHP Parallel Lint requirement.
- #880: Bump the minimum PHP version to 7.4, drop PHPUnit 8 support and fix CI.
- Rulesets:
- Sniffs:
- #843: Fix license information and standardise the file docblocks.
- #844: Remove
@sincetags which relate to WordPressCS. - #856: Classes/RestrictedExtendClasses: only listen for the
extendskeyword, significantly improving performance, and add tests. - #863: Functions/RestrictedFunctions: improve the
is_targetted_token()method. - #868: Security/Underscorejs: start using the PHPCSUtils
FilePathutility. - #870: Various minor CS fixes.
- Docs:
- QA:
- Tests:
- GitHub Actions:
Full Changelog: 3.0.1...3.1.0