Skip to content

Commit 31064cf

Browse files
committed
WP/I18n: remove the public check_translator_comments property
The `$check_translator_comments` property was introduced in WPCS `0.11.0` via PR 742 mostly to make our own lives easier managing the test case files. It allowed the pre-existing test case file `1` to remain largely unchanged, while the errors for translators comments were tested in a new test case file `2`. At the time, the ability to use modular ignore annotations, i.e. `// phpcs:disable Sniffcode`, did not exist yet. As those now _do_ exist and the minimum supported PHPCS version is beyond the version in which support for the modular ignore annotations was introduced, we can use those instead in the test case files and no longer need the property. For end-users, the use of the property has always been discouraged as they could exclude the error codes in their ruleset instead, so the impact of this change for end-users is expected to be minimal. The removal of the property should be annotated in the wiki when it is being updated for the release of WPCS 3.0.0. Related 1917.
1 parent 8009bbe commit 31064cf

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

WordPress/Sniffs/WP/I18nSniff.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,6 @@ final class I18nSniff extends AbstractFunctionParameterSniff {
122122
'_nx_noop' => 'noopnumber_context',
123123
);
124124

125-
/**
126-
* Toggle whether or not to check for translators comments for text string containing placeholders.
127-
*
128-
* Intended to make this part of the sniff unit testable, but can be used by end-users too,
129-
* though they can just as easily disable this via the sniff code.
130-
*
131-
* @since 0.11.0
132-
*
133-
* @var bool
134-
*/
135-
public $check_translator_comments = true;
136-
137125
/**
138126
* Whether or not the `default` text domain is one of the allowed text domains.
139127
*
@@ -411,9 +399,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
411399
/*
412400
* Check if a translators comments is necessary and if so, if it exists.
413401
*/
414-
if ( true === $this->check_translator_comments ) {
415-
$this->check_for_translator_comment( $stackPtr, $matched_content, $parameter_details );
416-
}
402+
$this->check_for_translator_comment( $stackPtr, $matched_content, $parameter_details );
417403
}
418404

419405
/**

WordPress/Tests/WP/I18nUnitTest.1.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// phpcs:set WordPress.WP.I18n check_translator_comments false
3+
// phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment -- Translator comment issues are tested in test case file 2.
44

55
__( 'string' ); // OK - no text domain known, so not checked.
66
__( 'string', 'something' ); // OK - no text domain known, so not checked.
@@ -302,4 +302,4 @@ _n_noop( domain: 'default' /*comment*/, singular: 'translate me', plural: 'trans
302302
_nx_noop( singular: 'translate me', domain /*comment*/: 'default', plural: 'translate me', context: 'context', ); // Bad: superfluous domain.
303303

304304
// phpcs:set WordPress.WP.I18n text_domain[]
305-
// phpcs:set WordPress.WP.I18n check_translator_comments true
305+
// phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment

WordPress/Tests/WP/I18nUnitTest.1.inc.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// phpcs:set WordPress.WP.I18n check_translator_comments false
3+
// phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment -- Translator comment issues are tested in test case file 2.
44

55
__( 'string' ); // OK - no text domain known, so not checked.
66
__( 'string', 'something' ); // OK - no text domain known, so not checked.
@@ -302,4 +302,4 @@ _n_noop( domain: 'default' /*comment*/, singular: 'translate me', plural: 'trans
302302
_nx_noop( singular: 'translate me', domain /*comment*/: 'default', plural: 'translate me', context: 'context', ); // Bad: superfluous domain.
303303

304304
// phpcs:set WordPress.WP.I18n text_domain[]
305-
// phpcs:set WordPress.WP.I18n check_translator_comments true
305+
// phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment

0 commit comments

Comments
 (0)