Skip to content

Commit

Permalink
Merge pull request #2233 from WordPress/feature/wp-i18n-adjust-sprint…
Browse files Browse the repository at this point in the history
…f-regexes-for-new-php-80-modifiers
  • Loading branch information
GaryJones committed Apr 24, 2023
2 parents d09d549 + 00dcc63 commit 119cc0c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions WordPress/Sniffs/WP/I18nSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class I18nSniff extends AbstractFunctionParameterSniff {
[0-9]+ # Width specifier.
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
)
[bcdeEfFgGosuxX] # Type specifier.
[bcdeEfFgGhHosuxX] # Type specifier.
)
)/x';

Expand All @@ -85,7 +85,7 @@ final class I18nSniff extends AbstractFunctionParameterSniff {
[0-9]+ # Width specifier.
(?:\.(?:[ 0]|\'.)?[0-9]+)? # Optional precision specifier with optional padding character.
)
[bcdeEfFgGosuxX] # Type specifier.
[bcdeEfFgGhHosuxX] # Type specifier.
)/x';

/**
Expand Down
3 changes: 3 additions & 0 deletions WordPress/Tests/WP/I18nUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,7 @@ esc_html_e( 'foo', '' ); // Bad: text domain mismatch.
// phpcs:set WordPress.WP.I18n text_domain[]
esc_html_e( 'foo', '' ); // Bad: text-domain can not be empty.

// PHP 8.0+: safeguard handling of newly introduced placeholders.
__( 'There are %1$h monkeys in the %H', 'my-slug' ); // Bad: multiple arguments should be numbered.

// phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment
3 changes: 3 additions & 0 deletions WordPress/Tests/WP/I18nUnitTest.1.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,7 @@ esc_html_e( 'foo', '' ); // Bad: text domain mismatch.
// phpcs:set WordPress.WP.I18n text_domain[]
esc_html_e( 'foo', '' ); // Bad: text-domain can not be empty.

// PHP 8.0+: safeguard handling of newly introduced placeholders.
__( 'There are %1$h monkeys in the %H', 'my-slug' ); // Bad: multiple arguments should be numbered.

// phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment
1 change: 1 addition & 0 deletions WordPress/Tests/WP/I18nUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function getErrorList( $testFile = '' ) {
306 => 1,
311 => 1,
315 => 1,
318 => 1,
);

case 'I18nUnitTest.2.inc':
Expand Down

0 comments on commit 119cc0c

Please sign in to comment.