-
-
Notifications
You must be signed in to change notification settings - Fork 523
Description
As noticed while working on #2518, the I18nTextDomainFixer sniff, which uses the AbstractFunctionParameterSniff abstract class, does not handle variable unpacking correctly. It throws a false positive when, at least in some cases, it should ignore a function call with variable unpacking.
For example, the code below triggers a warning, and it shouldn't:
<?php
// phpcs:set WordPress.Utils.I18nTextDomainFixer old_text_domain[] old-text-domain
// phpcs:set WordPress.Utils.I18nTextDomainFixer new_text_domain my-text-domain
__(...$args);vendor/bin/phpcs --standard=WordPress --sniffs=WordPress.Utils.I18nTextDomainFixer test.php -s
FILE: test.php
--------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------
6 | ERROR | [x] Missing $domain arg (WordPress.Utils.I18nTextDomainFixer.MissingArgDomain)
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------
As @jrfnl pointed out, all the sniffs using the same abstract should be checked (and fixed if necessary) to ensure they correctly handle variable unpacking.
Action list
To Do
-
WordPress.CodeAnalysis.EscapedNotTranslated -
WordPress.DateTime.CurrentTimeTimestamp -
WordPress.NamingConventions.PrefixAllGlobals -
WordPress.NamingConventions.ValidHookName -
WordPress.NamingConventions.ValidPostTypeSlug -
WordPress.PHP.IniSet -
WordPress.PHP.PregQuoteDelimiter -
WordPress.PHP.StrictInArray -
WordPress.Security.PluginMenuSlug -
WordPress.Utils.I18nTextDomainFixer -
WordPress.WP.Capabilities -
WordPress.WP.DeprecatedParameters -
WordPress.WP.DeprecatedParameterValues -
WordPress.WP.DiscouragedConstants -
WordPress.WP.EnqueuedResourceParameters -
WordPress.WP.GetMetaSingle -
WordPress.WP.I18n -
WordPress.WP.OptionAutoloadSniff(PR ✨ New WordPress.WP.OptionAutoload sniff #2520, not merged yet)
Want to contribute?
Leave a comment below to claim a sniff you'll be working on.
Leave another comment if nothing needs to be done for a given sniff, or create a PR if changes are necessary. PRs related to this task should preferably only contain changes for one sniff each.