Skip to content

Commit a0b76c6

Browse files
authored
Revert "feat(FunctionT): Allow passing constants to t() (#3326197 by Murz)"
1 parent e79554b commit a0b76c6

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ public function processFunctionCall(
7575
return;
7676
}
7777

78-
if ($tokens[$argument['start']]['code'] !== T_CONSTANT_ENCAPSED_STRING
79-
&& $tokens[$argument['start']]['code'] !== T_STRING
80-
&& $tokens[$argument['start']]['code'] !== T_SELF
81-
) {
78+
if ($tokens[$argument['start']]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
8279
// Not a translatable string literal.
8380
$warning = 'Only string literals should be passed to t() where possible';
8481
$phpcsFile->addWarning($warning, $argument['start'], 'NotLiteralString');

tests/Drupal/Semantics/FunctionTUnitTest.inc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,4 @@ class Test {
3434
return new TranslationWrapper(' Do not start with a space');
3535
}
3636

37-
public function testConstants() {
38-
// Using constants in t() should be allowed.
39-
$x = t(self::FOO);
40-
}
41-
4237
}
43-
44-
// Using constants in t() should be allowed.
45-
const FOO2 = 'bar2';
46-
$x = t(FOO2);
47-
$x = t(Test::FOO);

0 commit comments

Comments
 (0)