Skip to content

Commit

Permalink
Revert "feat(FunctionT): Allow passing constants to t() (#3326197 by …
Browse files Browse the repository at this point in the history
…Murz)"
  • Loading branch information
klausi authored Jul 17, 2023
1 parent e79554b commit a0b76c6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
5 changes: 1 addition & 4 deletions coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ public function processFunctionCall(
return;
}

if ($tokens[$argument['start']]['code'] !== T_CONSTANT_ENCAPSED_STRING
&& $tokens[$argument['start']]['code'] !== T_STRING
&& $tokens[$argument['start']]['code'] !== T_SELF
) {
if ($tokens[$argument['start']]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
// Not a translatable string literal.
$warning = 'Only string literals should be passed to t() where possible';
$phpcsFile->addWarning($warning, $argument['start'], 'NotLiteralString');
Expand Down
10 changes: 0 additions & 10 deletions tests/Drupal/Semantics/FunctionTUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,4 @@ class Test {
return new TranslationWrapper(' Do not start with a space');
}

public function testConstants() {
// Using constants in t() should be allowed.
$x = t(self::FOO);
}

}

// Using constants in t() should be allowed.
const FOO2 = 'bar2';
$x = t(FOO2);
$x = t(Test::FOO);

0 comments on commit a0b76c6

Please sign in to comment.